chman 发表于 2006-7-31 22:37:00

请教对选择集中的对象的判断条件

本帖最后由 作者 于 2006-8-8 15:22:00 编辑 <br /><br /> <P><FONT face=宋体 size=2>我的目的是:<BR>选择屏幕上所有的线<BR>然后按照图层,线型,线宽大小,颜色号等信息重新分层。<BR>补充一下程序的过滤器<BR>Sub tt()<BR>Dim tuceng1 As AcadSelectionSet<BR>Dim xzj As Object<BR>For Each xzj In ThisDrawing.SelectionSets<BR>If xzj.Name = "tuceng1" Then<BR>ThisDrawing.SelectionSets.Item("tuceng1").Delete<BR>End If<BR>Next<BR><BR>Dim FilterType(0 To 6) As Integer<BR>Dim FilterData(0 To 6) As Variant<BR>FilterType(0) = -4<BR>FilterData(0) = "&lt;or</FONT><FONT face=宋体 size=2><BR>FilterType(2) = 0<BR>FilterData(3) = "Line"<BR>FilterType(4) = 0<BR>FilterData(4) = "Polyline"<BR>FilterType(5) = 0<BR>FilterData(5) = "LWPolyline"<BR>FilterType(6) = -4<BR>FilterData(6) = "or&gt;<BR><BR>ss.Select acSelectionSetAll, , , FilterType, FilterData<BR>Dim ss As Object<BR>Set ss = ThisDrawing.SelectionSets.Add("tuceng1")<BR>ss.Select acSelectionSetAll<BR><BR>dim i as acadobject<BR>For Each i In ss<BR>If i.Layer = "tt" and i.ConstantWidth = 0.30 and i.color = 80 Then <BR>i.Layer = "kk1"<BR>Update<BR>elseif i.layer = "22" and i.ConstantWidth= 0.30 then <BR>i.layer= "kk2"<BR>End If<BR>Next<BR>End Sub<BR>个人觉的,如果可以用if来区分的话<BR>如上所示<BR>可能要简洁,易读一些<BR>我总共有一百多个图层<BR>如果每个层都用过滤器,程序可能会很冗长<BR></FONT></P>
<P><FONT face=宋体 size=2></FONT>&nbsp;</P>
<P><FONT face=宋体 size=2>现在图层用layer这个参数是正确的<BR>对选择集中的对象属性constantwidth有时正确有时错误</FONT></P>
<P><FONT face=宋体 size=2>color也有问题,其他的参数试了很多,就是不行</FONT></P>
<P>向大家求救了</P>

tnt1095 发表于 2006-7-31 23:14:00

i.lineweight= 0.30 肯定是有问题的

chman 发表于 2006-8-8 16:08:00

<P>上浮一次</P>
<P>&nbsp;</P>

wyj7485 发表于 2006-8-8 16:39:00

<P>'这样可以实现,其余部分自己加</P>
<P>Sub tt()<BR>Dim tuceng1 As AcadSelectionSet<BR>On Error Resume Next</P>
<P>Dim FilterType(0 To 6) As Integer<BR>Dim FilterData(0 To 6) As Variant<BR>FilterType(0) = -4<BR>FilterData(0) = "&lt;or"<BR>FilterType(2) = 0<BR>FilterData(3) = "Line"<BR>FilterType(4) = 0<BR>FilterData(4) = "Polyline"<BR>FilterType(5) = 0<BR>FilterData(5) = "LWPolyline"<BR>FilterType(6) = -4<BR>FilterData(6) = "or&gt;"</P>
<P>ThisDrawing.SelectionSets.Item("tuceng1").Delete<BR>Set tuceng1 = ThisDrawing.SelectionSets.Add("tuceng1")<BR>tuceng1.Select acSelectionSetAll, , , FilterType, FilterData</P>
<P>&nbsp;</P>
<P>Dim i As AcadLine<BR>For Each i In tuceng1<BR>If i.Lineweight = 30 Then'即线宽0.3<BR>i.Layer = "tt"<BR>Update<BR>End If<BR>Next</P>
<P>End Sub</P>

chman 发表于 2015-7-4 21:30:22

so good,现在回头看,判断为pline(line)才用i.Lineweight
页: [1]
查看完整版本: 请教对选择集中的对象的判断条件