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