- 积分
- 652
- 明经币
- 个
- 注册时间
- 2005-4-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
有如下代码用来删除指定区域内的块参照(Block Reference),可老是起不了作用啊!
怎么办?救救我啊
Public Sub DelBlock()
建立选择集setp和setb,分别用来选择围成区域的3维多段线,和块参照 Dim setb As AcadSelectionSet Dim setp As AcadSelectionSet Dim i As Integer Dim y As Integer Dim j As Integer Dim k As Integer
i = ThisDrawing.SelectionSets.Count
While (i) Set setb = ThisDrawing.SelectionSets.Item(i - 1) If setb.Name = "BlockR" Or setb.Name = "objlh" Then setb.Delete End If i = i - 1 Wend
Set setb = ThisDrawing.SelectionSets.Add("BlockR") Set setp = ThisDrawing.SelectionSets.Add("objlh")
Dim gpcode(1) As Integer Dim datavalue(1) As Variant
gpcode(0) = 0 datavalue(0) = "polyline" gpcode(1) = 8 datavalue(1) = "Pathh" setp.Select acSelectionSetAll, , , gpcode, datavalue
获得4条3维多段线的4个交点
Dim obj1 As Acad3DPolyline Dim obj2 As Acad3DPolyline Dim pnt As Variant Dim pt(0 To 4, 0 To 2) As Variant
For k = 0 To 4 For i = 0 To setp.Count - 1 Set obj1 = setp.Item(i) For j = i + 1 To setp.Count - 1 Set obj2 = setp.Item(j) pnt = obj1.IntersectWith(obj2, acExtendNone) If VarType(pnt) <> vbEmpty Then For y = LBound(pnt) To UBound(pnt) pt(k, y) = pnt(y) 'MsgBox "pt(" & k & "," & y & ")" & ":" & pt(k, y) Next y If k < 4 Then k = k + 1 End If End If Next j Next i Next k
setp.Erase
'把得到的点组成pointList
Dim pts(0 To 11) As Double For i = 0 To 11 For j = 1 To 4 For k = 0 To 2 pts(i) = pt(j, k) 'MsgBox pts(i) If i < 11 Then i = i + 1 End If Next k Next j Next i
用以上点绘制三维多段线
Dim objline As Acad3DPolyline Set objline = ThisDrawing.ModelSpace.Add3DPoly(pts)
选择3维多段线的角点中的两个点
Dim endpoint1(0 To 2) As Double Dim endpoint2(0 To 2) As Double Dim coord1 As Variant Dim coord2 As Variant
coord1 = objline.Coordinate(0) coord2 = objline.Coordinate(3)
endpoint1(0) = coord1(0): endpoint1(1) = coord1(1): endpoint1(2) = coord1(2) endpoint2(0) = coord2(0): endpoint2(1) = coord2(1): endpoint2(2) = coord2(2) objline.Delete
gpcode(0) = 0
datavalue(0) = "insert"
setb.Select acSelectionSetAll, endpoint1, endpoint2, gpcode, datavalue MsgBox setb.Count
setb.Erase End Sub
这里声明一下:一直到获得两个点的地方却正确,可就是不能够选择块参照
|
|