Public Sub text() On Error Resume Next Dim ptInsert As Variant Dim txtStr As String Dim height As Double Dim width As Double Dim angle As Double Dim SSet As AcadSelectionSet If Not IsNull(ThisDrawing.SelectionSets.Item("this")) Then Set SSet = ThisDrawing.SelectionSets.Item("this") SSet.Delete End If Set SSet = ThisDrawing.SelectionSets.Add("this") Dim FilterType(0 To 4) As Integer Dim FilterData(0 To 4) As Variant FilterType(0) = -4 FilterData(0) = "<or" FilterType(1) = 0 FilterData(1) = "text" FilterType(2) = 0 FilterData(2) = "TEXT" FilterType(3) = 0 FilterData(3) = A FilterType(4) = -4 FilterData(4) = "or>" SSet.Select acSelectionSetAll, , , FilterType, FilterData Dim objText As AcadText For Each objText In SSet ptInsert = objText.InsertionPoint txtStr = objText.TextString height = objText.height angle = objText.Rotation objText.Delete A = txtStr Dim B As Double B = Right(A, 3) Dim C As Double C = CInt(B) AddTextHA C, ptInsert, height, angle objText.Update Next SSet.Delete End Sub
X=123可以变为123,X=12.3变为2,X=1.23变为0 |