[讨论]关于选择集过滤器的问题,看问题出在哪里了?
简单说一下我的问题:我的图形里有很多线段,我要通过屏幕选择一部分,然后通过全选的方式选择余下的部分。
我写了部分代码,但是全选的时候出错了,选择不了所有蓝色的直线,请看代码:
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
本帖最后由 作者 于 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) = " <p>TO wylong :</p>
<p>刚运行了一下,也还是不行呢,在go to o的地方出错了:”标签未定义“。</p>
<p>能说一下我之前那个代码为啥选择不了想要的直线吗?<br/></p> <p>写错了 </p>
<p>On Error goto o改成On Error goto 0 <br/></p> <p>还是有错误,怎么在</p>
<p><font face="Verdana">MsgBox "选择Hub"<br/>Hubline.SelectOnScreen FilterTypeHS, FilterDataHS<br/>Hubline.Highlight (False)<br/>MsgBox "Hub计算站对象数:" & Hubline.Count</font></p>
<p> </p>
<p>这个地方出错了呢?出错信息是:“Filter list 在selectonscreen 中无效!”</p>
<p>奇怪啊,我检查了一遍,也没啥改动呀?还请指教啊</p> 你上面的代码我没改动过的,你自己好好检查一下吧 <p>我更改一下,还是不能选择蓝色的直线,真弄不明白了问题出在哪里呢?还请高手过来指点一二!谢谢了!</p>
<p> </p>
<p> </p>
<p><font face="Verdana">Sub FilterLine()<br/> On Error GoTo ErrorHandle</font></p>
<p><font face="Verdana"> Dim sslines As AcadSelectionSet<br/> Dim J1line As AcadSelectionSet<br/> Dim Hubline As AcadSelectionSet<br/> Dim Shroudline As AcadSelectionSet<br/> <br/> Dim FilterTypeJ1(0) As Integer<br/> Dim FilterDataJ1(0) As Variant<br/> Dim FilterTypeHS(5) As Integer<br/> Dim FilterDataHS(5) As Variant</font></p>
<p><font face="Verdana"> <br/> FilterTypeJ1(0) = 0<br/> FilterDataJ1(0) = "Line"<br/> <br/> FilterTypeHS(0) = -4<br/> FilterDataHS(0) = "<or"<br/> FilterTypeHS(1) = 0<br/> FilterDataHS(1) = "POLYLINE"<br/> FilterTypeHS(2) = 0<br/> FilterDataHS(2) = "SPline"<br/> FilterTypeHS(3) = 0<br/> FilterDataHS(3) = "Line"<br/> FilterTypeHS(4) = 0<br/> FilterDataHS(4) = "Arc"<br/> FilterTypeHS(5) = -4<br/> FilterDataHS(5) = "or>"<br/> <br/> On Error Resume Next<br/> AppActivate "AutoCAD 2008"<br/> ThisDrawing.SelectionSets("J1").Delete<br/> ThisDrawing.SelectionSets("Hub").Delete<br/> ThisDrawing.SelectionSets("Shroud").Delete</font></p>
<p><font face="Verdana"> Set J1line = ThisDrawing.SelectionSets.Add("J1")<br/> Set Hubline = ThisDrawing.SelectionSets.Add("Hub")<br/> Set Shroudline = ThisDrawing.SelectionSets.Add("Shroud")<br/> <br/> <br/> <br/> MsgBox "选择J=1计算站"<br/> J1line.SelectOnScreen FilterTypeJ1, FilterDataJ1<br/> J1line.Highlight (False)<br/> MsgBox "J=1计算站对象数:" & J1line.count<br/> <br/> MsgBox "选择Hub"<br/> Hubline.SelectOnScreen FilterTypeHS, FilterDataHS<br/> Hubline.Highlight (False)<br/> MsgBox "Hub计算站对象数:" & Hubline.count<br/> <br/> MsgBox "选择Shroud"<br/> Shroudline.SelectOnScreen FilterTypeHS, FilterDataHS<br/> Shroudline.Highlight (False)<br/> MsgBox "Shroud计算站对象数:" & Shroudline.count<br/> <br/> <br/> Dim FilterType1(1) As Integer<br/> Dim FilterData1(1) As Variant<br/> <br/> 'FilterType1(0) = -4<br/> 'FilterData1(0) = "<and"<br/> <br/> FilterType1(0) = 0<br/> FilterData1(0) = "Line"<br/> FilterType1(1) = 62<br/> FilterData1(1) = 5<br/> <br/> 'FilterType1(3) = -4<br/> 'FilterData1(3) = "and>"<br/> 'FilterType1(3) = 10<br/> 'FilterData1(3) = 868#<br/> 'FilterType1(4) = -4<br/> 'FilterData1(4) = "and>"<br/> <br/> On Error Resume Next<br/> Set ss2lines = ThisDrawing.SelectionSets.Add("SSets2")<br/> <br/> ss2lines.Select acSelectionSetAll, , , FilterType1, FilterData1<br/> <br/> i = ss2lines.count<br/> MsgBox "全部对象数:" & i<br/> </font></p>
<p><font face="Verdana"> <br/> 'Dim E As AcadEntity<br/> 'For Each E In ss2lines<br/> ' MsgBox E.ObjectName<br/> ' i = 1<br/> ' If (i = 1) Then<br/> ' End<br/> ' End If<br/> <br/> ' Next E</font></p>
<p><font face="Verdana"> <br/> i = ss2lines.count<br/> MsgBox "所需对象数:" & i<br/> <br/> <br/> <br/> ss2lines.Delete<br/> J1line.Delete<br/> Hubline.Delete<br/> Shroudline.Delete<br/> <br/> <br/> Exit Sub<br/>ErrorHandle:<br/> <br/> ThisDrawing.SelectionSets("J1").Delete<br/> ThisDrawing.SelectionSets("Hub").Delete<br/> ThisDrawing.SelectionSets("Shroud").Delete<br/> ThisDrawing.SelectionSets("SSets2").Delete</font></p><font face="Verdana">
<p><br/>End Sub</p>
<p></font> </p>
<p></p> <p>选择蓝色线,过滤器这样设置有问题吗?</p>
<p> FilterType1(0) = 0<br/> FilterData1(0) = "Line"<br/> FilterType1(1) = 62<br/> FilterData1(1) = 5<br/></p> 请问这个问题最后怎么解决了,谢谢,我也遇到这方面的问题,谢谢
页:
[1]