请教!大侠们帮忙看看这段炸开块参照的代码有误吗?
始终是报错: autocad输入错误。这是小弟编写的一段练习代码,用来炸开dwg中的所有块参照的。
Function ExplodeAllRef() As Boolean<BR>Dim Refs As AcadBlockReference<BR>Dim AcadObject1 As AcadEntity<BR>Dim flag As Boolean<BR>Dim acadRef As AcadBlockReference
While flag = True<BR> flag = False<BR> For Each AcadObject1 In ThisDrawing.ModelSpace<BR> If AcadObject1.ObjectName = "AcDbBlockReference" Then
flag = True<BR> <BR> AcadObject1.Explode<BR> <BR> End If<BR> Next<BR>Wend
End Function<BR>算法是土了些,但是看过程没有大问题啊。
而且图中不存在无法炸开的块参照。
编辑器报错的那个块参照我用explode命令是可以炸开的啊。
请明总和各位高手指点下吧!
谢谢了! 本帖最后由 作者 于 2005-4-11 23:21:00 编辑
外面的While循环有什么用?完全多余 用来解决嵌套的问题啊。 Sub tt()
On Error Resume Next
Dim i As AcadBlockReference
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("Test").Delete
Set ss = ThisDrawing.SelectionSets.Add("Test")
Dim ft(0) As Integer, fd(0)
ft(0) = 0: fd(0) = "Insert"
ss.Select acSelectionSetAll, , , ft, fd
For Each i In ss
MyExplode i
Next
ss.Delete
End Sub Sub MyExplode(oBlk As AcadBlockReference)
'功能:炸开嵌套块
Dim i, objs
Dim j As AcadBlockReference
objs = oBlk.Explode
oBlk.Delete
For i = 0 To UBound(objs)
If objs(i).ObjectName = "AcDbBlockReference" Then
Set j = objs(i)
MyExplode j
End If
Next i
End Sub 学习中。。。谢谢版主!
用递归来解决嵌套问题,是个好办法。
页:
[1]