- Sub AddNum()
- Dim Txt As AcadText
- Dim Obj As AcadEntity
- Dim strTxt As String
- Dim rTxt As String
- strTxt = ThisDrawing.Utility.GetString(0, vbCrLf & " 输入文字的前缀<P>:")
- If strTxt = "" Then strTxt = "P"
- For Each Obj In ThisDrawing.ModelSpace
- If Obj.ObjectName = "AcDbText" Then
- Set Txt = Obj
- rTxt = Right(Txt.TextString, Len(Txt.TextString) - Len(strTxt))
- If Left(Txt.TextString, Len(strTxt)) = strTxt And (Val(rTxt) <> 0 Or rTxt = "0") Then
- Txt.TextString = strTxt + Trim(Str(Val(rTxt) + 1))
- End If
- End If
- Next Obj
- Update
- End Sub
|