本帖最后由 tth02 于 2011-7-13 15:18 编辑
用vba写了一个,可以实线楼主图片中展示的功能。
代码如下:
 - Sub add200()
- Dim SSet As AcadSelectionSet, objText As AcadText, str1 As String
- Dim n As Integer, ii As Integer, jj As Integer
- Do While ThisDrawing.SelectionSets.count > 0
- ThisDrawing.SelectionSets.Item(0).Delete
- Loop
- n = ThisDrawing.Utility.GetInteger("输入需要增加的数字,负数表示减:")
- Set SSet = ThisDrawing.SelectionSets.Add("add200")
- Dim ft(0) As Integer, fd(0) As Variant
- ft(0) = 0
- fd(0) = "TEXT"
- SSet.SelectOnScreen ft, fd
- For Each objText In SSet
- str1 = objText.TextString
- For ii = 1 To Len(str1)
- If Mid(str1, ii, 1) > "0" Then Exit For
- Next ii
- str1 = Right(str1, Len(str1) - ii + 1)
- str1 = CStr(CInt(str1) + n)
- For jj = 1 To ii - 1
- str1 = "0" & str1
- Next jj
- objText.TextString = str1
- Next objText
- End Sub
|