求不规则多边形面域的程序。
Public Function Updateregon()Dim p(7) As Double
Dim lwpolyObj As AcadLWPolyline
p(0) = 0.8: p(1) = 0
p(2) = 1.3: p(3) = 1.1
p(4) = 0.5: p(5) = 1.1
p(6) = 0.5: p(7) = 0
Set lwpolyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
lwpolyObj.Closed = True
'余下如下把lwpolyObj生成一个面域?请教
End Function
Public Function Updateregon()
Dim p(7) As Double
Dim lwpolyObj As AcadLWPolyline
p(0) = 0.8: p(1) = 0
p(2) = 1.3: p(3) = 1.1
p(4) = 0.5: p(5) = 1.1
p(6) = 0.5: p(7) = 0
Set lwpolyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
lwpolyObj.Closed = True
'余下如下把lwpolyObj生成一个面域?请教
Dim curves(0) As AcadEntity
Set curves(0) = lwpolyObj
' 创建面域
Dim regionObj As Variant
regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
ZoomAll
End Function
zzyong00 发表于 2014-10-25 17:32 static/image/common/back.gif
多谢高手,请继续赐教。
实现这个,我的问题就解决了。下一步把这几个数据搞到窗体中去折腾一下。
Sub bb()
Dim p(7) As Double
Dim lwpolyObj As AcadLWPolyline
p(0) = 0.8: p(1) = 0
p(2) = 1.3: p(3) = 2.1
p(4) = 0.5: p(5) = 2.1
p(6) = 0#: p(7) = 0.3
Set lwpolyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(p)
lwpolyObj.Closed = True
Dim curves(0) As AcadEntity
Set curves(0) = lwpolyObj
Dim regionObj(0) As Variant
regionObj(0) = ThisDrawing.ModelSpace.AddRegion(curves)
'改变其图层及颜色,并求x质心
Dim reg As AcadRegion
Set reg = regionObj(0)'为何转化不成功?或者直接用
reg.Layer = "MMM"
reg.color = acRed
msbox "x质心为:" & reg.Centroid(0)
End Sub ThisDrawing.ModelSpace.AddRegion(curves) 返回数组!
Set reg = regionObj(0)(0)'试 谢谢了。大致明白意思了。
个数组,还以为Variant是任一。
页:
[1]