明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2108|回复: 8

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

[复制链接]
发表于 2010-10-21 09:17:00 | 显示全部楼层 |阅读模式
简单说一下我的问题:
我的图形里有很多线段,我要通过屏幕选择一部分,然后通过全选的方式选择余下的部分。
我写了部分代码,但是全选的时候出错了,选择不了所有蓝色的直线,请看代码:
  1. Sub FilterLine()
  2.    On Error GoTo ErrorHandle
  3.    Dim sslines As AcadSelectionSet
  4.    Dim J1line As AcadSelectionSet
  5.    Dim Hubline As AcadSelectionSet
  6.    Dim Shroudline As AcadSelectionSet
  7.    
  8.    Dim FilterTypeJ1(0) As Integer
  9.    Dim FilterDataJ1(0) As Variant
  10.    Dim FilterTypeHS(5) As Integer
  11.    Dim FilterDataHS(5) As Variant
  12.       
  13.    FilterTypeJ1(0) = 0
  14.    FilterDataJ1(0) = "Line"
  15.    
  16.    FilterTypeHS(0) = -4
  17.    FilterDataHS(0) = "<or"
  18.    FilterTypeHS(1) = 0
  19.    FilterDataHS(1) = "POLYLINE"
  20.    FilterTypeHS(2) = 0
  21.    FilterDataHS(2) = "SPline"
  22.    FilterTypeHS(3) = 0
  23.    FilterDataHS(3) = "Line"
  24.    FilterTypeHS(4) = 0
  25.    FilterDataHS(4) = "Arc"
  26.    FilterTypeHS(5) = -4
  27.    FilterDataHS(5) = "or>"
  28.   
  29.    Set J1line = ThisDrawing.SelectionSets.Add("J1")
  30.    Set Hubline = ThisDrawing.SelectionSets.Add("Hub")
  31.    Set Shroudline = ThisDrawing.SelectionSets.Add("Shroud")
  32.    
  33.    AppActivate "AutoCAD 2008"
  34.       
  35.    MsgBox "选择J=1计算站"
  36.    J1line.SelectOnScreen FilterTypeJ1, FilterDataJ1
  37.    J1line.Highlight (False)
  38.    MsgBox "J=1计算站对象数:" & J1line.Count
  39.       
  40.    MsgBox "选择Hub"
  41.    Hubline.SelectOnScreen FilterTypeHS, FilterDataHS
  42.    Hubline.Highlight (False)
  43.    MsgBox "Hub计算站对象数:" & Hubline.Count
  44.          
  45.    MsgBox "选择Shroud"
  46.    Shroudline.SelectOnScreen FilterTypeHS, FilterDataHS
  47.    Shroudline.Highlight (False)
  48.    MsgBox "Shroud计算站对象数:" & Shroudline.Count
  49.    
  50.    
  51.    Dim FilterType1(3) As Integer
  52.    Dim FilterData1(3) As Variant
  53.    
  54.   '以下的过滤代码好像有问题,选择的时候不起作用,选不了蓝色的线,试了好几种情况都不行,把and 去掉也不行,加上也不行!
  55.    FilterType1(0) = -4
  56.    FilterData1(0) = "<and"
  57.    FilterType1(1) = 0
  58.    FilterData1(1) = "Line"
  59.    FilterType1(2) = 62
  60.    FilterData1(2) = 5
  61.    FilterType1(3) = -4
  62.    FilterData1(3) = "and>"
  63.    'FilterType1(3) = 10
  64.    'FilterData1(3) = 868#
  65.    'FilterType1(4) = -4
  66.    'FilterData1(4) = "and>"
  67.    
  68.       
  69.    Set ss2lines = ThisDrawing.SelectionSets.Add("SSets2")
  70.    ss2lines.Select acSelectionSetAll, , , FilterType1, FilterData1
  71.    
  72.    i = ss2lines.Count
  73.    MsgBox "全部对象数:" & i
  74.    
  75.       
  76.    'Dim E As AcadEntity
  77.    'For Each E In ss2lines
  78.    '   MsgBox E.ObjectName
  79.    '   i = 1
  80.    '   If (i = 1) Then
  81.    '    End
  82.    '   End If
  83.    
  84.   ' Next E
  85.    
  86.    i = ss2lines.Count
  87.    MsgBox "所需对象数:" & i
  88.    
  89.    
  90.       
  91.    ss2lines.Delete
  92.    J1line.Delete
  93.    Hubline.Delete
  94.    Shroudline.Delete
  95.    
  96.    
  97.    Exit Sub
  98. ErrorHandle:
  99.    
  100.    ThisDrawing.SelectionSets("J1").Delete
  101.    ThisDrawing.SelectionSets("Hub").Delete
  102.    ThisDrawing.SelectionSets("Shroud").Delete
  103.    ThisDrawing.SelectionSets("SSets2").Delete
  104. End Sub
发表于 2010-10-21 10:18:00 | 显示全部楼层
本帖最后由 作者 于 2010-10-21 13:13:09 编辑

  1. Sub FilterLine()
  2. On Error GoTo ErrorHandle
  3. Dim sslines As AcadSelectionSet
  4. Dim J1line As AcadSelectionSet
  5. Dim Hubline As AcadSelectionSet
  6. Dim Shroudline As AcadSelectionSet
  7. Dim FilterTypeJ1(0) As Integer
  8. Dim FilterDataJ1(0) As Variant
  9. Dim FilterTypeHS(5) As Integer
  10. Dim FilterDataHS(5) As Variant
  11. FilterTypeJ1(0) = 0
  12. FilterDataJ1(0) = "Line"
  13. FilterTypeHS(0) = -4
  14. FilterDataHS(0) = "
 楼主| 发表于 2010-10-21 13:06:00 | 显示全部楼层

TO wylong :

刚运行了一下,也还是不行呢,在go to o的地方出错了:”标签未定义“。

能说一下我之前那个代码为啥选择不了想要的直线吗?

发表于 2010-10-21 13:14:00 | 显示全部楼层

写错了 

On Error goto o改成On Error goto 0 

 楼主| 发表于 2010-10-21 13:39:00 | 显示全部楼层

还是有错误,怎么在

MsgBox "选择Hub"
Hubline.SelectOnScreen FilterTypeHS, FilterDataHS
Hubline.Highlight (False)
MsgBox "Hub计算站对象数:" & Hubline.Count

 

这个地方出错了呢?出错信息是:“Filter list 在selectonscreen 中无效!”

奇怪啊,我检查了一遍,也没啥改动呀?还请指教啊

发表于 2010-10-21 20:01:00 | 显示全部楼层
你上面的代码我没改动过的,你自己好好检查一下吧
 楼主| 发表于 2010-10-22 09:14: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>"
 
   On Error Resume Next
   AppActivate "AutoCAD 2008"
   ThisDrawing.SelectionSets("J1").Delete
   ThisDrawing.SelectionSets("Hub").Delete
   ThisDrawing.SelectionSets("Shroud").Delete

   Set J1line = ThisDrawing.SelectionSets.Add("J1")
   Set Hubline = ThisDrawing.SelectionSets.Add("Hub")
   Set Shroudline = ThisDrawing.SelectionSets.Add("Shroud")
  
 
     
   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(1) As Integer
   Dim FilterData1(1) As Variant
  
   'FilterType1(0) = -4
   'FilterData1(0) = "<and"
  
   FilterType1(0) = 0
   FilterData1(0) = "Line"
   FilterType1(1) = 62
   FilterData1(1) = 5
  
   'FilterType1(3) = -4
   'FilterData1(3) = "and>"
   'FilterType1(3) = 10
   'FilterData1(3) = 868#
   'FilterType1(4) = -4
   'FilterData1(4) = "and>"
  
   On Error Resume Next
   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-22 09:15:00 | 显示全部楼层

选择蓝色线,过滤器这样设置有问题吗?

   FilterType1(0) = 0
   FilterData1(0) = "Line"
   FilterType1(1) = 62
   FilterData1(1) = 5

发表于 2015-11-5 23:40:19 | 显示全部楼层
请问这个问题最后怎么解决了,谢谢,我也遇到这方面的问题,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 09:28 , Processed in 0.189542 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表