yuangw1234 发表于 2006-8-13 18:23:00

以下程式无法颜色过滤

<P>问题如下:</P>
<P>假如一条线的颜色是红色,另一条是绿色,颜色不用ByLayer,程式有过滤作用;可是当都是ByLayer刚失效,用此程式失效的结果是两条线都被选择,请问如何解决,本以为将obj.color改成obj.Truecolor,结果不对</P>
<P>Public Sub Ys()<BR>On Error Resume Next<BR>Dim Ssetobj As AcadSelectionSet, Str As Integer, Obj As AcadEntity, Pt As Variant<BR>ThisDrawing.Utility.GetEntity Obj, Pt: Obj.Highlight True<BR>Str = Obj.color<BR>ThisDrawing.SelectionSets("ys").Delete<BR>Err.Clear<BR>Set Ssetobj = ThisDrawing.SelectionSets.Add("ys")<BR>Dim Ftype(1) As Integer, Fdata(1) As Variant<BR>Ftype(0) = 0<BR>Fdata(0) = "*"<BR>Ftype(1) = 62<BR>Fdata(1) = Str<BR>Ssetobj.SelectOnScreen Ftype, Fdata<BR>End Sub<BR></P>

fjfhgdwfn 发表于 2006-8-13 18:48:00

如果bylayer 哪就再判断下层的颜色吧

yuangw1234 发表于 2006-8-14 08:12:00

請問一下,下層的顏色是什麼意思?能不能用VBA關鍵字提示一下

fjfhgdwfn 发表于 2006-8-14 08:34:00

<P>判断下层的颜色</P>
<P>先得到object.layer,</P>
<P>再判断</P>
<P>layer.color</P>

yuangw1234 发表于 2006-8-14 12:05:00

<P>先謝謝,我去試試</P>

yuangw1234 发表于 2006-8-14 13:34:00

試了一下,好象不行,大師可不可以在我的程式上修改一下,就如選擇的參考物體的顏色是綠色,那麼我就只要過濾綠色的物體,不管Bylayer是綠色,還是實際是綠色

雪山飞狐_lzh 发表于 2006-8-14 15:12:00

<P>引用我的增强选择集类(在我的博客里找:)),运行下面的程序</P>
<P>Sub ttx()<BR>&nbsp;&nbsp;&nbsp; Dim ss As New TlsSelectSet<BR>&nbsp;&nbsp;&nbsp; ss.Init<BR>&nbsp;&nbsp;&nbsp; ss.Filter.SetData -4, "&lt;or", 62, acRed<BR>&nbsp;&nbsp;&nbsp; For Each i In ThisDrawing.Layers<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If i.Color = acRed Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss.Filter.AppendData -4, "&lt;and", 8, i.Name, 62, acByLayer, -4, "and&gt;"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; ss.Filter.AppendData -4, "or&gt;"<BR>&nbsp;&nbsp;&nbsp; ss.SelectObject acSelectionSetAll<BR>&nbsp;&nbsp;&nbsp; MsgBox ss.Count<BR>End Sub<BR></P>
<P>或者</P>
<P>Sub ttx()<BR>&nbsp;&nbsp;&nbsp; Dim ss As New TlsSelectSet<BR>&nbsp;&nbsp;&nbsp; ss.Init<BR>&nbsp;&nbsp;&nbsp; For Each i In ThisDrawing.Layers<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If i.Color = acRed Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = s &amp; i.Name &amp; ","<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; s = Left(s, Len(s) - 1)<BR>&nbsp;&nbsp;&nbsp; ss.Filter.SetData -4, "&lt;or", 62, acRed, -4, "&lt;and", 8, s, 62, acByLayer, -4, "and&gt;", -4, "or&gt;"<BR>&nbsp;&nbsp;&nbsp; ss.SelectObject acSelectionSetAll<BR>&nbsp;&nbsp;&nbsp; MsgBox ss.Count<BR>End Sub<BR></P>

yuangw1234 发表于 2006-8-15 08:37:00

<P>请问一下版主,你的那个New TlsSelectSet 是自定义的变量,它是acadselectionset还是什么呢?能不能把那个自定义的变量也发上来,因为我用你的程式,发现也找不到 Init这个属性<BR></P>

雪山飞狐_lzh 发表于 2006-8-15 08:55:00

<P>不是让你在我的博客上找了么:)</P>
<P>还是贴过来吧:)</P>
<P>下面的代码放在TlsSelectSet类模块中</P>
<P><A href="http://xsfhlzh.139.com/article/325507.html" target="_blank" >http://xsfhlzh.139.com/article/325507.html</A></P>
<P>下面的模块放在TlsResultBuffer类模块中</P>
<P><A href="http://xsfhlzh.139.com/article/332841.html" target="_blank" >http://xsfhlzh.139.com/article/332841.html</A></P>

yuangw1234 发表于 2006-8-15 11:37:00

先謝謝版主
页: [1]
查看完整版本: 以下程式无法颜色过滤