创建区域
让我猜个谜,如果帮助文件说一个区域是从一条多段线创建的,为什么这行不通Public Sub wall()
Dim dblLength As Double, dblWidth As Double, dblHeight As Double
Dim inspt(2) As Double, endpt(2) As Double
inspt(0) = 120: inspt(1) = 120: inspt(2) = 0
Dim oLayer As AcadLayer, oCurrLayeR As AcadLayer, oBlock As AcadBlockReference, _
oEntity As AcadEntity, newObjs As Variant ', InsPT As Variant
Set oCurrLayeR = ThisDrawing.ActiveLayer
Set oLayer = ThisDrawing.Layers.Add("SITE-WALL")
oLayer.color = 1
ThisDrawing.ActiveLayer = oLayer
' dblLength = CDbl(txtLength.Value)
' dblWidth = CDbl(txtWidth.Value)
' dblHeight = CDbl(txtHeight.Value)
dblLength = 144
dblWidth = 72
dblHeight = 60
Dim WallCoords(9) As Double
WallCoords(0) = inspt(0) - (dblLength / 2): WallCoords(1) = inspt(1) + (dblWidth / 2)
WallCoords(2) = inspt(0) + (dblLength / 2): WallCoords(3) = inspt(1) + (dblWidth / 2)
WallCoords(4) = inspt(0) + (dblLength / 2): WallCoords(5) = inspt(1) - (dblWidth / 2)
WallCoords(6) = inspt(0) - (dblLength / 2): WallCoords(7) = inspt(1) - (dblWidth / 2)
WallCoords(8) = inspt(0) - (dblLength / 2): WallCoords(9) = inspt(1) + (dblWidth / 2)
Dim plineObj As AcadLWPolyline
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(WallCoords)
plineObj.Closed = True
Dim regionObj As Variant
Set regionObj = ThisDrawing.ModelSpace.AddRegion(plineObj)
ZoomAll
ThisDrawing.ActiveLayer = oCurrLayeR
End Sub
您传递的项目必须是一个对象数组…
Public Sub wall()
Dim dblLength As Double, dblWidth As Double, dblHeight As Double
Dim inspt(2) As Double, endpt(2) As Double
inspt(0) = 120: inspt(1) = 120: inspt(2) = 0
Dim oLayer As AcadLayer, oCurrLayeR As AcadLayer, oBlock As AcadBlockReference, _
oEntity As AcadEntity, newObjs As Variant ', InsPT As Variant
Set oCurrLayeR = ThisDrawing.ActiveLayer
Set oLayer = ThisDrawing.layers.Add("SITE-WALL")
oLayer.Color = 1
ThisDrawing.ActiveLayer = oLayer
' dblLength = CDbl(txtLength.Value)
' dblWidth = CDbl(txtWidth.Value)
' dblHeight = CDbl(txtHeight.Value)
dblLength = 144
dblWidth = 72
dblHeight = 60
Dim WallCoords(9) As Double
WallCoords(0) = inspt(0) - (dblLength / 2): WallCoords(1) = inspt(1) + (dblWidth / 2)
WallCoords(2) = inspt(0) + (dblLength / 2): WallCoords(3) = inspt(1) + (dblWidth / 2)
WallCoords(4) = inspt(0) + (dblLength / 2): WallCoords(5) = inspt(1) - (dblWidth / 2)
WallCoords(6) = inspt(0) - (dblLength / 2): WallCoords(7) = inspt(1) - (dblWidth / 2)
WallCoords(8) = inspt(0) - (dblLength / 2): WallCoords(9) = inspt(1) + (dblWidth / 2)
Dim objArray(0) As AcadEntity
Set objArray(0) = ThisDrawing.ModelSpace.AddLightWeightPolyline(WallCoords)
objArray(0).Closed = True
ThisDrawing.ModelSpace.AddRegion objArray
ZoomAll
ThisDrawing.ActiveLayer = oCurrLayeR
End Sub
我又迟到了Public Sub wall()
Dim dblLength As Double, dblWidth As Double, dblHeight As Double
Dim inspt(2) As Double, endpt(2) As Double
inspt(0) = 120: inspt(1) = 120: inspt(2) = 0
Dim oLayer As AcadLayer, oCurrLayeR As AcadLayer, oBlock As AcadBlockReference, _
oEntity As AcadEntity, newObjs As Variant ', InsPT As Variant
Set oCurrLayeR = ThisDrawing.ActiveLayer
Set oLayer = ThisDrawing.Layers.Add("SITE-WALL")
oLayer.color = 1
ThisDrawing.ActiveLayer = oLayer
' dblLength = CDbl(txtLength.Value)
' dblWidth = CDbl(txtWidth.Value)
' dblHeight = CDbl(txtHeight.Value)
dblLength = 144
dblWidth = 72
dblHeight = 60
Dim WallCoords(9) As Double
WallCoords(0) = inspt(0) - (dblLength / 2): WallCoords(1) = inspt(1) + (dblWidth / 2)
WallCoords(2) = inspt(0) + (dblLength / 2): WallCoords(3) = inspt(1) + (dblWidth / 2)
WallCoords(4) = inspt(0) + (dblLength / 2): WallCoords(5) = inspt(1) - (dblWidth / 2)
WallCoords(6) = inspt(0) - (dblLength / 2): WallCoords(7) = inspt(1) - (dblWidth / 2)
WallCoords(8) = inspt(0) - (dblLength / 2): WallCoords(9) = inspt(1) + (dblWidth / 2)
Dim plineObj As AcadLWPolyline
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(WallCoords)
plineObj.Closed = True
Dim bound(0) As AcadEntity
Set bound(0) = plineObj
Dim regionObj As Variant
regionObj = ThisDrawing.ModelSpace.AddRegion(bound)
plineObj.Delete
ZoomAll
ThisDrawing.ActiveLayer = oCurrLayeR
End Sub 让我看看我是否理解,我们正在使用通用的AcadEntity,创建一个LWP作为所述实体,并将其传递给region命令? 基本上..除了AddRegion方法的参数必须是一个实体数组之外…
即
Dim NumberOfEntities, X As Integer
NumberOfEntities = 10
Dim EntityArray(0 to NumberOfEntities) As AcadEntity
For X = 0 to NumberOfEntities
Set EntityArray(X) = MakePline() <--- dummy function returning a LWpolyline
Next X
ThisDrawing.ModelSpace.AddRegion(EntityArray)
不,您创建LWP,并将其放入数组中。将数组传递给.addregion命令。It#039;如果你';只传递一个对象,但如果使用3个对象来定义区域,则有意义
将其总结为:LWP=addlwpoly(blah)
dim arregionbound(0)as variant
arregionbond(0)=LWPregionObj=ThisDrawing.ModelSpace。AddRegion(arrRegionBound)
编辑:正如quickfingersKeith所说。 沿着这些相同的线……你怎么能找到一个区域的中心? 也许这会有帮助?
页:
[1]