lency 发表于 2009-9-21 10:39:00

图纸编号程序求助

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

lency 发表于 2009-9-21 10:51:00

我用了两个嵌套的循环语句,但是不太了解CAD里对象和属性,没弄成,请哪个高手指教下小弟!
页: [1]
查看完整版本: 图纸编号程序求助