tiger0101 发表于 2007-10-11 11:20:00

请问vba如何实现选择图层为"aa",块名不是"405"的所有图元

<p>&nbsp;&nbsp;&nbsp;&nbsp; 请问vba如何实现选择图层为"aa",块名不是"405"的所有图元</p><p>&nbsp;&nbsp;&nbsp;&nbsp; 事实上,"aa"层中只应该有块名是“405”的块,我是要把除块名为"405"的其它块选出来标识错误。&nbsp;&nbsp;&nbsp;&nbsp;</p><p>&nbsp;&nbsp;&nbsp;&nbsp; 这个选择语句如何实现</p>

zzcctt 发表于 2007-10-15 08:59:00

<p>dim II as integer</p><p>Dim gpCode(0 To 0) As Integer<br/>&nbsp;&nbsp;&nbsp; Dim DateValue(0 To 01) As Variant<br/>&nbsp;&nbsp;&nbsp; gpCode(0) = 0<br/>&nbsp;&nbsp;&nbsp; DateValue(0) =&nbsp;<font color="#ff0000"> LayName'图层名自己输入</font><font color="#ff0000"><br/></font>&nbsp;&nbsp;&nbsp; Dim Filtertype As Variant, FilterDate As Variant<br/>&nbsp;&nbsp;&nbsp; Filtertype = gpCode<br/>&nbsp;&nbsp;&nbsp; FilterDate = DateValue<br/>&nbsp;&nbsp;&nbsp; Dim SSetObj As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; If ThisDrawing.SelectionSets.Count &lt;&gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For II = 0 To ThisDrawing.SelectionSets.Count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SSetObj = ThisDrawing.SelectionSets.Item(II)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSetObj.Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set SSetObj = ThisDrawing.SelectionSets.Add("AA")<br/>&nbsp;&nbsp;&nbsp; SSetObj.Select acSelectionSetAll, , , Filtertype, FilterDate'这是选择指定图层上所有的物体</p><p>&nbsp;Dim BLK As AcadBlockReference<br/>&nbsp;&nbsp;&nbsp; For II = SSetObj.Count - 1 To 0 Step -1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If SSetObj.Item(I).ObjectName = "AcDbBlockReference" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set BLK = SSetObj.Item(I)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If BLK.Name&nbsp;&lt;&gt; "405" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'自己写要操作的代码</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next<br/></p><p></p><p><br/></p>

yusicad 发表于 2007-10-16 17:26:00

<p>&nbsp;&nbsp; Set BLK = SSetObj.Item(I)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If BLK.Name&nbsp;&lt;&gt; "405" Then<br/></p><p>&nbsp;好顶一下</p>

fjfhgdwfn 发表于 2007-10-16 20:58:00

<p>&nbsp;Dim FilterType(2) As Integer<br/>&nbsp;&nbsp; Dim FilterData(2) As Variant<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; FilterType(0) =&nbsp;8</p><p>&nbsp;&nbsp; FilterData(0) = "aa"</p><p>&nbsp;&nbsp; FilterType(1) =&nbsp;-4</p><p>&nbsp;&nbsp; FilterData(1) = "/="&nbsp; '不是&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; FilterType(2) =&nbsp;2<br/>&nbsp;&nbsp; FilterData(2) = "块名"&nbsp; '块名&nbsp;&nbsp;&nbsp;</p><p>这样应好一些<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
页: [1]
查看完整版本: 请问vba如何实现选择图层为"aa",块名不是"405"的所有图元