我想编一个自动给图纸编号的程序,功能是给定一个之前编号中字符串和一个新编号的前缀,选择图中包含字符串的文字,然后按照屏幕中从左到右的顺序按照一定格式的前缀重新编号。 程序结构如下: '第一部分:定义选择集,用来存放需要重新编号的旧图纸编号 Dim qbhwenzi As String Dim hbhwenzi As String qbhwenzi = beforetext.text editbh.Hide On Error Resume Next Dim sset As AcadSelectionSet If Not IsNull(ThisDrawing.SelectionSets.Item("example")) Then Set sset = ThisDrawing.SelectionSets.Item("example") sset.Delete End If Set sset = ThisDrawing.SelectionSets.Add("example") '第二部分:获取包含特定字符串的旧图纸编号,并存入选择集 Dim FilterType(1) As Integer Dim FilterData(1) As Variant FilterType(0) = 0 FilterData(0) = "TEXT" FilterType(1) = 1 FilterData(1) = qbhwenzi + "**" sset.SelectOnScreen FilterType, FilterData Dim i As Integer Dim k As Integer Dim text1 As Variant Dim addtext As String Dim a As Integer Dim j As Integer '取得选择集元素的个数 a = 0 For Each text1 In sset a = a + 1 Next text1 '第三部分:按照选择集中文字插入点X坐标从小到大的顺序,构建一个新的选择集,数组中元素按照从小到大排列 不知道怎么实现!!!! '第四部分:'按照顺序更换新选择集中图纸编号 For i = 1 To a If i < 10 Then addtext = "0" & i sset2.Item(i - 1).TextString = latertext + addtext Else addtext = i sset2.Item(i - 1).TextString = latertext + addtext End If Next |