czj 发表于 2005-1-25 12:48:00

[VBA] 如何解决块的重名问题

假如原来的块为         mxb1         再此插入时 为 mxb2
依次累加

my_computer 发表于 2005-1-25 14:50:00

同样的块使用相同的名字有很多好处,比如统计,修改等;不知你要达到什么功能。如果你坚持自己的想法,可以用块的句柄加编号形成块的指针,然后将它保存在图形中。

czj 发表于 2005-1-25 14:50:00

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]
查看完整版本: [VBA] 如何解决块的重名问题