不错的思路,但这样的程序只能使用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
- Dim EntityInBlock As AcadEntity
- For Each EntityInBlock In ThisDrawing.ObjectIdToObject(BlkId)
- If EntityInBlock.ObjectName = "AcDbMText" Then
- TextString = EntityInBlock.TextString
- Exit For
- End If
- Next
- 'Debug.Print TextString
- If TextString <> "" Then ThisDrawing.ObjectIdToObject(contextdata(0)).TextOverride = TextString
- End If
-
- End Sub
|