chen_0801 发表于 2008-12-18 12:14:00

[求助]只把图层打开的对象加入到选择集遇到问题

<p>各位高手,麻烦你们帮帮我 看看程序,我只想把图层设置为打开的那些实体对象加入到选择集,可以下面的代码却没有把任何对象加入到选择集,请帮我看看问题出在什么地方了 谢谢</p><p>'把图层设置为关闭的过滤掉<br/>&nbsp;&nbsp;&nbsp; Dim entry As AcadLayer<br/>&nbsp;&nbsp;&nbsp; ReDim filterdata(0 To ThisDrawing.Layers.Count - 1) As String<br/>&nbsp;&nbsp;&nbsp; Dim NO1 As Integer<br/>&nbsp;&nbsp;&nbsp; NO1 = 0<br/>&nbsp;&nbsp;&nbsp; '遍历图层<br/>&nbsp;&nbsp;&nbsp; For Each entry In ThisDrawing.Layers<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If entry.LayerOn = True Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filterdata(NO1) = entry.Name<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; '定义选择集过滤器<br/>&nbsp;&nbsp;&nbsp; Dim filterTYPE1() As Integer<br/>&nbsp;&nbsp;&nbsp; Dim filterDATA1() As String<br/>&nbsp;&nbsp;&nbsp; Dim e1 As Integer<br/>&nbsp;&nbsp;&nbsp; For e1 = 0 To NO1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filterTYPE1(e1) = 8<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filterDATA1(e1) = filterdata(e1)<br/>&nbsp;&nbsp;&nbsp; Next e1<br/>&nbsp;&nbsp;&nbsp; ssetObj.Select acSelectionSetAll, , , filterTYPE1, filterDATA1</p>

mccad 发表于 2008-12-18 12:36:00

<p>你没有加入“OR”的逻辑,所以就变成了“AND”了。</p><p>如果只是OR,可以把所有图层用逗号隔开,所以上面的程序可以简单化,&nbsp;只需要把过滤的图层名组合在一行里用逗号隔开。</p>

gdzhou 发表于 2008-12-18 14:29:00

<p>dim n as integer,i as integer</p><p>dim ft(0) as integer</p><p>dim fd(0) </p><p>ft(0)=8</p><p>dim Sl() as string</p><p>n=-1</p><p>for i=0 to thisdrawing.layers.count-1</p><p>if thisdrawing.layers(i).layeron=true then</p><p>&nbsp;&nbsp;&nbsp; n=n+1</p><p>redim preserve sl(n)</p><p>&nbsp; sl(n)=thisdrawing.layers(i).name</p><p>endif</p><p>next i</p><p>fd(0)=join(sl,",")</p><p>dim sset as acadselection</p><p>.......</p><p>....</p>

chen_0801 发表于 2008-12-18 15:32:00

<p>真心感谢 上面两位。</p>
页: [1]
查看完整版本: [求助]只把图层打开的对象加入到选择集遇到问题