luna125 发表于 2010-10-21 09:17:00

[讨论]关于选择集过滤器的问题,看问题出在哪里了?

简单说一下我的问题:
我的图形里有很多线段,我要通过屏幕选择一部分,然后通过全选的方式选择余下的部分。
我写了部分代码,但是全选的时候出错了,选择不了所有蓝色的直线,请看代码:


Sub FilterLine()
   On Error GoTo ErrorHandle
   Dim sslines As AcadSelectionSet
   Dim J1line As AcadSelectionSet
   Dim Hubline As AcadSelectionSet
   Dim Shroudline As AcadSelectionSet
   
   Dim FilterTypeJ1(0) As Integer
   Dim FilterDataJ1(0) As Variant
   Dim FilterTypeHS(5) As Integer
   Dim FilterDataHS(5) As Variant
      
   FilterTypeJ1(0) = 0
   FilterDataJ1(0) = "Line"
   
   FilterTypeHS(0) = -4
   FilterDataHS(0) = "<or"
   FilterTypeHS(1) = 0
   FilterDataHS(1) = "POLYLINE"
   FilterTypeHS(2) = 0
   FilterDataHS(2) = "SPline"
   FilterTypeHS(3) = 0
   FilterDataHS(3) = "Line"
   FilterTypeHS(4) = 0
   FilterDataHS(4) = "Arc"
   FilterTypeHS(5) = -4
   FilterDataHS(5) = "or>"


   Set J1line = ThisDrawing.SelectionSets.Add("J1")
   Set Hubline = ThisDrawing.SelectionSets.Add("Hub")
   Set Shroudline = ThisDrawing.SelectionSets.Add("Shroud")
   
   AppActivate "AutoCAD 2008"
      
   MsgBox "选择J=1计算站"
   J1line.SelectOnScreen FilterTypeJ1, FilterDataJ1
   J1line.Highlight (False)
   MsgBox "J=1计算站对象数:" & J1line.Count
      
   MsgBox "选择Hub"
   Hubline.SelectOnScreen FilterTypeHS, FilterDataHS
   Hubline.Highlight (False)
   MsgBox "Hub计算站对象数:" & Hubline.Count
         
   MsgBox "选择Shroud"
   Shroudline.SelectOnScreen FilterTypeHS, FilterDataHS
   Shroudline.Highlight (False)
   MsgBox "Shroud计算站对象数:" & Shroudline.Count
   
   
   Dim FilterType1(3) As Integer
   Dim FilterData1(3) As Variant
   
'以下的过滤代码好像有问题,选择的时候不起作用,选不了蓝色的线,试了好几种情况都不行,把and 去掉也不行,加上也不行!
   FilterType1(0) = -4
   FilterData1(0) = "<and"
   FilterType1(1) = 0
   FilterData1(1) = "Line"
   FilterType1(2) = 62
   FilterData1(2) = 5
   FilterType1(3) = -4
   FilterData1(3) = "and>"
   'FilterType1(3) = 10
   'FilterData1(3) = 868#
   'FilterType1(4) = -4
   'FilterData1(4) = "and>"
   
      
   Set ss2lines = ThisDrawing.SelectionSets.Add("SSets2")
   ss2lines.Select acSelectionSetAll, , , FilterType1, FilterData1
   
   i = ss2lines.Count
   MsgBox "全部对象数:" & i
   
      
   'Dim E As AcadEntity
   'For Each E In ss2lines
   '   MsgBox E.ObjectName
   '   i = 1
   '   If (i = 1) Then
   '    End
   '   End If
   
' Next E
   
   i = ss2lines.Count
   MsgBox "所需对象数:" & i
   
   
      
   ss2lines.Delete
   J1line.Delete
   Hubline.Delete
   Shroudline.Delete
   
   
   Exit Sub
ErrorHandle:
   
   ThisDrawing.SelectionSets("J1").Delete
   ThisDrawing.SelectionSets("Hub").Delete
   ThisDrawing.SelectionSets("Shroud").Delete
   ThisDrawing.SelectionSets("SSets2").Delete

End Sub

wylong 发表于 2010-10-21 10:18:00

本帖最后由 作者 于 2010-10-21 13:13:09 编辑


Sub FilterLine()
On Error GoTo ErrorHandle
Dim sslines As AcadSelectionSet
Dim J1line As AcadSelectionSet
Dim Hubline As AcadSelectionSet
Dim Shroudline As AcadSelectionSet

Dim FilterTypeJ1(0) As Integer
Dim FilterDataJ1(0) As Variant
Dim FilterTypeHS(5) As Integer
Dim FilterDataHS(5) As Variant

FilterTypeJ1(0) = 0
FilterDataJ1(0) = "Line"

FilterTypeHS(0) = -4
FilterDataHS(0) = "

luna125 发表于 2010-10-21 13:06:00

<p>TO wylong :</p>
<p>刚运行了一下,也还是不行呢,在go to o的地方出错了:”标签未定义“。</p>
<p>能说一下我之前那个代码为啥选择不了想要的直线吗?<br/></p>

wylong 发表于 2010-10-21 13:14:00

<p>写错了&nbsp;</p>
<p>On Error&nbsp;goto&nbsp;o改成On Error&nbsp;goto&nbsp;0&nbsp;<br/></p>

luna125 发表于 2010-10-21 13:39:00

<p>还是有错误,怎么在</p>
<p><font face="Verdana">MsgBox "选择Hub"<br/>Hubline.SelectOnScreen FilterTypeHS, FilterDataHS<br/>Hubline.Highlight (False)<br/>MsgBox "Hub计算站对象数:" &amp; Hubline.Count</font></p>
<p>&nbsp;</p>
<p>这个地方出错了呢?出错信息是:“Filter list 在selectonscreen 中无效!”</p>
<p>奇怪啊,我检查了一遍,也没啥改动呀?还请指教啊</p>

wylong 发表于 2010-10-21 20:01:00

你上面的代码我没改动过的,你自己好好检查一下吧

luna125 发表于 2010-10-22 09:14:00

<p>我更改一下,还是不能选择蓝色的直线,真弄不明白了问题出在哪里呢?还请高手过来指点一二!谢谢了!</p>
<p> </p>
<p>&nbsp;</p>
<p><font face="Verdana">Sub FilterLine()<br/>&nbsp;&nbsp; On Error GoTo ErrorHandle</font></p>
<p><font face="Verdana">&nbsp;&nbsp; Dim sslines As AcadSelectionSet<br/>&nbsp;&nbsp; Dim J1line As AcadSelectionSet<br/>&nbsp;&nbsp; Dim Hubline As AcadSelectionSet<br/>&nbsp;&nbsp; Dim Shroudline As AcadSelectionSet<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; Dim FilterTypeJ1(0) As Integer<br/>&nbsp;&nbsp; Dim FilterDataJ1(0) As Variant<br/>&nbsp;&nbsp; Dim FilterTypeHS(5) As Integer<br/>&nbsp;&nbsp; Dim FilterDataHS(5) As Variant</font></p>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; FilterTypeJ1(0) = 0<br/>&nbsp;&nbsp; FilterDataJ1(0) = "Line"<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; FilterTypeHS(0) = -4<br/>&nbsp;&nbsp; FilterDataHS(0) = "&lt;or"<br/>&nbsp;&nbsp; FilterTypeHS(1) = 0<br/>&nbsp;&nbsp; FilterDataHS(1) = "POLYLINE"<br/>&nbsp;&nbsp; FilterTypeHS(2) = 0<br/>&nbsp;&nbsp; FilterDataHS(2) = "SPline"<br/>&nbsp;&nbsp; FilterTypeHS(3) = 0<br/>&nbsp;&nbsp; FilterDataHS(3) = "Line"<br/>&nbsp;&nbsp; FilterTypeHS(4) = 0<br/>&nbsp;&nbsp; FilterDataHS(4) = "Arc"<br/>&nbsp;&nbsp; FilterTypeHS(5) = -4<br/>&nbsp;&nbsp; FilterDataHS(5) = "or&gt;"<br/>&nbsp;<br/>&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp; AppActivate "AutoCAD 2008"<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("J1").Delete<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("Hub").Delete<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("Shroud").Delete</font></p>
<p><font face="Verdana">&nbsp;&nbsp; Set J1line = ThisDrawing.SelectionSets.Add("J1")<br/>&nbsp;&nbsp; Set Hubline = ThisDrawing.SelectionSets.Add("Hub")<br/>&nbsp;&nbsp; Set Shroudline = ThisDrawing.SelectionSets.Add("Shroud")<br/>&nbsp;&nbsp; <br/>&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; MsgBox "选择J=1计算站"<br/>&nbsp;&nbsp; J1line.SelectOnScreen FilterTypeJ1, FilterDataJ1<br/>&nbsp;&nbsp; J1line.Highlight (False)<br/>&nbsp;&nbsp; MsgBox "J=1计算站对象数:" &amp; J1line.count<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; MsgBox "选择Hub"<br/>&nbsp;&nbsp; Hubline.SelectOnScreen FilterTypeHS, FilterDataHS<br/>&nbsp;&nbsp; Hubline.Highlight (False)<br/>&nbsp;&nbsp; MsgBox "Hub计算站对象数:" &amp; Hubline.count<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; MsgBox "选择Shroud"<br/>&nbsp;&nbsp; Shroudline.SelectOnScreen FilterTypeHS, FilterDataHS<br/>&nbsp;&nbsp; Shroudline.Highlight (False)<br/>&nbsp;&nbsp; MsgBox "Shroud计算站对象数:" &amp; Shroudline.count<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; Dim FilterType1(1) As Integer<br/>&nbsp;&nbsp; Dim FilterData1(1) As Variant<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; 'FilterType1(0) = -4<br/>&nbsp;&nbsp; 'FilterData1(0) = "&lt;and"<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; FilterType1(0) = 0<br/>&nbsp;&nbsp; FilterData1(0) = "Line"<br/>&nbsp;&nbsp; FilterType1(1) = 62<br/>&nbsp;&nbsp; FilterData1(1) = 5<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; 'FilterType1(3) = -4<br/>&nbsp;&nbsp; 'FilterData1(3) = "and&gt;"<br/>&nbsp;&nbsp; 'FilterType1(3) = 10<br/>&nbsp;&nbsp; 'FilterData1(3) = 868#<br/>&nbsp;&nbsp; 'FilterType1(4) = -4<br/>&nbsp;&nbsp; 'FilterData1(4) = "and&gt;"<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp; Set ss2lines = ThisDrawing.SelectionSets.Add("SSets2")<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; ss2lines.Select acSelectionSetAll, , , FilterType1, FilterData1<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; i = ss2lines.count<br/>&nbsp;&nbsp; MsgBox "全部对象数:" &amp; i<br/>&nbsp;&nbsp; </font></p>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; 'Dim E As AcadEntity<br/>&nbsp;&nbsp; 'For Each E In ss2lines<br/>&nbsp;&nbsp; '&nbsp;&nbsp; MsgBox E.ObjectName<br/>&nbsp;&nbsp; '&nbsp;&nbsp; i = 1<br/>&nbsp;&nbsp; '&nbsp;&nbsp; If (i = 1) Then<br/>&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; End<br/>&nbsp;&nbsp; '&nbsp;&nbsp; End If<br/>&nbsp;&nbsp; <br/>&nbsp; ' Next E</font></p>
<p><font face="Verdana">&nbsp;&nbsp; <br/>&nbsp;&nbsp; i = ss2lines.count<br/>&nbsp;&nbsp; MsgBox "所需对象数:" &amp; i<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; ss2lines.Delete<br/>&nbsp;&nbsp; J1line.Delete<br/>&nbsp;&nbsp; Hubline.Delete<br/>&nbsp;&nbsp; Shroudline.Delete<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; Exit Sub<br/>ErrorHandle:<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("J1").Delete<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("Hub").Delete<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("Shroud").Delete<br/>&nbsp;&nbsp; ThisDrawing.SelectionSets("SSets2").Delete</font></p><font face="Verdana">
<p><br/>End Sub</p>
<p></font>&nbsp;</p>
<p></p>

luna125 发表于 2010-10-22 09:15:00

<p>选择蓝色线,过滤器这样设置有问题吗?</p>
<p>&nbsp;&nbsp; FilterType1(0) = 0<br/>&nbsp;&nbsp; FilterData1(0) = "Line"<br/>&nbsp;&nbsp; FilterType1(1) = 62<br/>&nbsp;&nbsp; FilterData1(1) = 5<br/></p>

懵懂少年 发表于 2015-11-5 23:40:19

请问这个问题最后怎么解决了,谢谢,我也遇到这方面的问题,谢谢
页: [1]
查看完整版本: [讨论]关于选择集过滤器的问题,看问题出在哪里了?