VBA是能做的,怎么会无法提取块中的各个对象呢?在图形中选择块,就可以得到块名,通过块名就可以查到块定义,你可以通过遍历的方法来查看块定义中的所有图元。
如果使用GetSubEntity方法,可以参考以下程序:
-
- Sub FixDimText()
- Dim Ent As AcadEntity
- Dim Pnt As Variant
- ThisDrawing.Utility.GetSubEntity Ent, Pnt, transMatrix, contextdata, "选择标注对象:"
- Dim BlkId As Long
- BlkId = Ent.OwnerID
- Dim BlkName As String
- Dim TextString As String
- BlkName = ThisDrawing.ObjectIdToObject(BlkId).Name
- If Left(BlkName, 2) = "*D" Then
- If Ent.ObjectName = "AcDbMText" Then
- TextString = Ent.TextString
- If TextString "" Then ThisDrawing.ObjectIdToObject(contextdata(0)).TextOverride = TextString
- End If
- End If
- End Sub
|