有没什么简便方法删除当前模型空间里某一区域内的所有块呢?
是这样的,在层ExtrudeFace和层zz-1里面分别有很多插入的块----树和路灯,现在要把在某个实体的上面的树和路灯删除,要怎么办呢?是不是应该建立选择集?怎么样设置过滤条件呢? 应该建立选择集,过滤的条件是这两个层中的某个区域的对象。区域可以是矩形区域或多边形区域。<BR>选择完对象后使用Erase方法来删除选择集及对象。 就如下图所示,我删除4条3dpoly线围成区域内的所有块!要怎么办呢?我自己写了点代码,但运行老是出错,帮我看看好吗?<A name=34831><FONT color=#990000><B>mccad</B></FONT></A>
Public Sub DelBlock()
定义选择集setb和setp分别用于选择块和4条3dpolyline线<BR>Dim setb As AcadSelectionSet<BR>Dim setp As AcadSelectionSet<BR>Dim i As Integer
i = ThisDrawing.SelectionSets.Count
While (i)<BR>Set setb = ThisDrawing.SelectionSets.Item(i - 1)<BR>If setb.Name = "BlockR" Or setb.Name = "objlh" Then<BR> setb.Delete<BR>End If<BR>i = i - 1<BR>Wend
Set setb = ThisDrawing.SelectionSets.Add("BlockR")<BR>Set setp = ThisDrawing.SelectionSets.Add("objlh")
Dim gpcode(1) As Integer<BR>Dim datavalue(1) As Variant
gpcode(0) = 0<BR>datavalue(0) = "polyline"<BR>gpcode(1) = 8<BR>datavalue(1) = "Pathh"<BR>setp.Select acSelectionSetAll, , , gpcode, datavalue
查找选择集setp中两条相交polyline,把交点返回个cwp1,并把这两条线删除
Dim obj1 As Acad3DPolyline<BR>Dim obj2 As Acad3DPolyline<BR>Dim cwp1 As Variant<BR>Dim cwp2 As Variant<BR>Dim pnt As Variant<BR>Set obj1 = setp.Item(0)<BR>For i = 1 To setp.Count - 1<BR> Set obj2 = setp.Item(i)<BR> pnt = obj1.IntersectWith(obj2, acExtendNone)<BR> <BR> If VarType(pnt) <> vbEmpty Then<BR> Set cwp1 = pnt<BR> setp.Item(0).Delete<BR> setp.Item(i).Delete<BR> Exit For<BR> End If<BR>Next i
查找剩下的两条相交线,把交点返回给cwp2<BR>Set obj1 = setp.Item(0)<BR>For i = 1 To setp.Count - 1<BR> Set obj2 = setp.Item(i)<BR> pnt = obj1.IntersectWith(obj2, acExtendNone)<BR> If VarType(pnt) <> vbEmpty Then<BR> Set cwp2 = pnt<BR> setp.Item(0).Delete<BR> setp.Item(i).Delete<BR> Exit For<BR> End If<BR>Next i
setp.erase
选择区域内的块,清空!
gpcode(0) = 2<BR>datavalue(0) = "BlockReference"
setb.Select acSelectionSetCrossing, cwp1, cwp2, gpcode, datavalue<BR>setb.Erase<BR> <BR>End Sub
http://请输入地址c 惨了,我现在不知道怎么把自己电脑上面的图片给贴上来了!
真是的!
页:
[1]