ft630712 发表于 2008-9-28 20:56:00

autocad vba 选择集过滤器问题

<p>&nbsp;autocad vba 选择集过滤器问题
                </p><p></p><p>以下代码运行不正常 <br/>Sub aa() <br/>On Error GoTo errcontrol <br/>&nbsp; <br/>&nbsp; &nbsp; '创建选择集 <br/>&nbsp; &nbsp; Set FilterSet = ThisDrawing.SelectionSets.Add("xxx") <br/>&nbsp; &nbsp; <br/>&nbsp; &nbsp; Dim FilterType(0 To 1) As Integer <br/>&nbsp; &nbsp; Dim FilterData(0 To 1) As Variant <br/>&nbsp; &nbsp; '设置过滤器类型 <br/>&nbsp; &nbsp; FilterType(0) = 0 <br/>&nbsp; &nbsp; FilterType(1) = 0 <br/>&nbsp; &nbsp; '设置过滤数据 <br/>&nbsp; &nbsp; FilterData(0) = "line" <br/>&nbsp; &nbsp; FilterData(1) = "arc" <br/>&nbsp; &nbsp; '使用过滤器,由用户在屏幕上选择 <br/>&nbsp; &nbsp; FilterSet.SelectOnScreen FilterType, FilterData <br/>&nbsp; &nbsp; <br/>&nbsp; &nbsp; <br/><br/>errcontrol: <br/>&nbsp; ThisDrawing.SelectionSets("xxx").Delete <br/><br/>End Sub <br/>而这段代码却运行正常, <br/>Sub aa() <br/>On Error GoTo errcontrol <br/>&nbsp; <br/>&nbsp; &nbsp; '创建选择集 <br/>&nbsp; &nbsp; Set FilterSet = ThisDrawing.SelectionSets.Add("xxx") <br/>&nbsp; &nbsp; <br/>&nbsp; &nbsp; Dim FilterType(0 ) As Integer <br/>&nbsp; &nbsp; Dim FilterData(0 ) As Variant <br/>&nbsp; &nbsp; '设置过滤器类型 <br/>&nbsp; &nbsp; FilterType(0) = 0 <br/>&nbsp; &nbsp; &nbsp; &nbsp; '设置过滤数据 <br/>&nbsp; &nbsp; FilterData(0) = "line" <br/>&nbsp; &nbsp; &nbsp; '使用过滤器,由用户在屏幕上选择 <br/>&nbsp; &nbsp; FilterSet.SelectOnScreen FilterType, FilterData <br/>errcontrol: <br/>&nbsp; ThisDrawing.SelectionSets("xxx").Delete <br/><br/>End Sub <br/>那我想同时选择两种对象怎样写代码</p>

mccad 发表于 2008-9-29 07:42:00

可以用第二种方法,过滤数据改成:<br/>FilterData(0) = "line,arc"

sailorcwx 发表于 2008-9-30 13:41:00

<p>你这样写line和arc就是and的关系,CAD里面没有图元即是line也是arc的,所以你选不到,可以按2楼说的,也可以这样写,把关系写出来</p><p>Sub aa() <br/>On Error GoTo errcontrol <br/>&nbsp; <br/>&nbsp; &nbsp; '创建选择集 <br/>&nbsp; &nbsp; Set FilterSet = ThisDrawing.SelectionSets.Add("xxx")&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; Dim FilterType(0 To 3) As Integer<br/>&nbsp;&nbsp;&nbsp; Dim FilterData(0 To 3) As Variant<br/>&nbsp;&nbsp;&nbsp; '设置过滤器类型<br/>&nbsp;&nbsp;&nbsp; FilterType(0) = -4<br/>&nbsp;&nbsp;&nbsp; FilterType(1) = 0<br/>&nbsp;&nbsp;&nbsp; FilterType(2) = 0<br/>&nbsp;&nbsp;&nbsp; FilterType(3) = -4<br/>&nbsp;&nbsp;&nbsp; '设置过滤数据<br/>&nbsp;&nbsp;&nbsp; FilterData(0) = "&lt;or"<br/>&nbsp;&nbsp;&nbsp; FilterData(1) = "arc"<br/>&nbsp;&nbsp;&nbsp; FilterData(2) = "line"<br/>&nbsp;&nbsp;&nbsp; FilterData(3) = "or&gt;"<br/>&nbsp;&nbsp;&nbsp; '使用过滤器,由用户在屏幕上选择<br/>&nbsp;&nbsp;&nbsp; FilterSet.SelectOnScreen FilterType, FilterData&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; <br/><br/>errcontrol: <br/>&nbsp; ThisDrawing.SelectionSets("xxx").Delete <br/><br/>End Sub </p>

style6301 发表于 2008-10-3 23:11:00

经常可以看到有人发选择集问题的贴子,是否可以将这个作为一个专题来做一个详细的教程。

mccad 发表于 2008-10-4 09:03:00

<p>这个建议不错。</p><p>过滤器问题从2000年大家开始尝试使用VBA编程时就开始有相关的提问,到现在在网上也没有详细的教程。</p><p>自己写过相关的内容(当时是为了某本书),但后来并没有发表,过段时间找找把那段内容放出来。</p>

cnks 发表于 2008-10-4 12:51:00

mccad发表于2008-10-4 9:03:00static/image/common/back.gif这个建议不错。过滤器问题从2000年大家开始尝试使用VBA编程时就开始有相关的提问,到现在在网上也没有详细的教程。自己写过相关的内容(当时是为了某本书),但后来并没有发表,过段时间找找把那

<p>支持明总!</p>

dchlmz 发表于 2008-10-23 10:11:00

非常支持

huerfei008 发表于 2010-6-15 17:15:00

<div>可以用,这个方法比较好</div>
<div>设置过滤器类型<br/>&nbsp;&nbsp;&nbsp; FilterType(0) = -4<br/>&nbsp;&nbsp;&nbsp; FilterType(1) = 0<br/>&nbsp;&nbsp;&nbsp; FilterType(2) = 0<br/>&nbsp;&nbsp;&nbsp; FilterType(3) = -4<br/>&nbsp;&nbsp;&nbsp; '设置过滤数据<br/>&nbsp;&nbsp;&nbsp; FilterData(0) = "&lt;or"<br/>&nbsp;&nbsp;&nbsp; FilterData(1) = "arc"<br/>&nbsp;&nbsp;&nbsp; FilterData(2) = "line"<br/>&nbsp;&nbsp;&nbsp; FilterData(3) = "or&gt;"<br/></div>

luna125 发表于 2010-10-22 10:03:00

<p>支持,</p>
<p>是应该出点选择集的专题了,我在这论坛上找了好多,很多人咨询这个关于选择集的问题!明总出个专题吧!</p>
页: [1]
查看完整版本: autocad vba 选择集过滤器问题