[VBA] 如何解决块的重名问题
假如原来的块为 mxb1 再此插入时 为 mxb2依次累加 同样的块使用相同的名字有很多好处,比如统计,修改等;不知你要达到什么功能。如果你坚持自己的想法,可以用块的句柄加编号形成块的指针,然后将它保存在图形中。 Public Function block_count() As Integer
Dim BlockObj As AcadBlock
Dim n As Integer
For Each BlockObj In acadDoc.Application.ActiveDocument.Blocks
If Trim(Mid(BlockObj.Name, 1, 3)) = "mxb " Then
n = n + 1
End If
Next
block_count = n
Set BlockObj = Nothing
End Function
"""'"""""" = "mxb" & Trim(Str(block_count()))
页:
[1]