程序为把标注中的<>变为实际数值
但是我在一些图中测试成功,但在一些复杂的图形中的标注无法完全把 标注中的<>变为实际数值
望高手指点,在线等~~~~~~~~~~~
Public keyWord As String Public m As Integer Public n As Integer Public Sub SelfOverRide(objDim As AcadSelectionSet) Dim objBlk As AcadBlock Dim objEnt As AcadEntity Dim objEnt2 As AcadEntity Dim varPos As Variant Dim varInsPnt As Variant Dim objDimText As AcadMText Dim objBlocks As AcadBlocks Dim blnDone As Boolean 'On Error Resume Next Set objBlocks = ThisDrawing.Blocks 'varPos = objDim.TextPosition 'For Each objBlk In objBlocks ' If Not blnDone Then m = 0 n = 0 For Each objEnt2 In objDim If TypeOf objEnt2 Is AcadDimension Then varPos = objEnt2.TextPosition m = m + 1 For Each objBlk In objBlocks If Left(objBlk.Name, 2) = "*D" Then For Each objEnt In objBlk If TypeOf objEnt Is AcadMText Then Set objDimText = objEnt varInsPnt = objDimText.InsertionPoint If varInsPnt(0) = varPos(0) Then If varInsPnt(1) = varPos(1) Then If keyWord = "T" Then objEnt2.TextOverride = objDimText.TextString Else objEnt2.TextOverride = "<>" End If n = n + 1 Exit For End If End If End If Next objEnt End If Next objBlk End If Next objEnt2 'Else ' Exit For ' End If
End Sub
Sub DIMtext() Dim strPrmt As String Dim objEnt As AcadEntity Dim varPnt As Variant Dim IsDimension As Boolean Dim objDim As AcadDimension Dim SS As AcadSelectionSet
On Error Resume Next strPrmt = vbCr & "选择标注对象:" ThisDrawing.Utility.InitializeUserInput 1, "T A" keyWord = ThisDrawing.Utility.GetKeyword _ ("选择标注形式 (文字(T)/自动(A)): ") ThisDrawing.Utility.Prompt strPrmt ThisDrawing.SelectionSets.Item("SS1").Delete Set SS = ThisDrawing.SelectionSets.Add("SS1") SS.SelectOnScreen
SelfOverRide SS ThisDrawing.Utility.Prompt "共选择尺寸标注" & m & "个," & "转换成功" & n & "个." Exit Sub
End Sub
我发现主要问题是出在标注文字的插入点和CAD摸板空间中对应的MTEXT文字块插入点不一样如何解决???
varPos = objEnt2.TextPosition
不等于
varInsPnt = objDimText.InsertionPoint If varInsPnt(0) = varPos(0) Then If varInsPnt(1) = varPos(1) Then