明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1636|回复: 4

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

[复制链接]
发表于 2006-7-31 22:37:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2006-8-8 15:22:00 编辑

我的目的是:
选择屏幕上所有的线
然后按照图层,线型,线宽大小,颜色号等信息重新分层。
补充一下程序的过滤器
Sub tt()
Dim tuceng1 As AcadSelectionSet
Dim xzj As Object
For Each xzj In ThisDrawing.SelectionSets
If xzj.Name = "tuceng1" Then
ThisDrawing.SelectionSets.Item("tuceng1").Delete
End If
Next

Dim FilterType(0 To 6) As Integer
Dim FilterData(0 To 6) As Variant
FilterType(0) = -4
FilterData(0) = "<or

FilterType(2) = 0
FilterData(3) = "Line"
FilterType(4) = 0
FilterData(4) = "Polyline"
FilterType(5) = 0
FilterData(5) = "LWPolyline"
FilterType(6) = -4
FilterData(6) = "or>

ss.Select acSelectionSetAll, , , FilterType, FilterData
Dim ss As Object
Set ss = ThisDrawing.SelectionSets.Add("tuceng1")
ss.Select acSelectionSetAll

dim i as acadobject
For Each i In ss
If i.Layer = "tt" and i.ConstantWidth = 0.30 and i.color = 80 Then
i.Layer = "kk1"
Update
elseif i.layer = "22" and i.ConstantWidth= 0.30 then
i.layer= "kk2"
End If
Next
End Sub
个人觉的,如果可以用if来区分的话
如上所示
可能要简洁,易读一些
我总共有一百多个图层
如果每个层都用过滤器,程序可能会很冗长

 

现在图层用layer这个参数是正确的
对选择集中的对象属性constantwidth有时正确有时错误

color也有问题,其他的参数试了很多,就是不行

向大家求救了

发表于 2006-7-31 23:14:00 | 显示全部楼层
i.lineweight  = 0.30 肯定是有问题的
 楼主| 发表于 2006-8-8 16:08:00 | 显示全部楼层

上浮一次

 

发表于 2006-8-8 16:39:00 | 显示全部楼层

'这样可以实现,其余部分自己加

Sub tt()
Dim tuceng1 As AcadSelectionSet
On Error Resume Next

Dim FilterType(0 To 6) As Integer
Dim FilterData(0 To 6) As Variant
FilterType(0) = -4
FilterData(0) = "<or"
FilterType(2) = 0
FilterData(3) = "Line"
FilterType(4) = 0
FilterData(4) = "Polyline"
FilterType(5) = 0
FilterData(5) = "LWPolyline"
FilterType(6) = -4
FilterData(6) = "or>"

ThisDrawing.SelectionSets.Item("tuceng1").Delete
Set tuceng1 = ThisDrawing.SelectionSets.Add("tuceng1")
tuceng1.Select acSelectionSetAll, , , FilterType, FilterData

 

Dim i As AcadLine
For Each i In tuceng1
If i.Lineweight = 30 Then'即线宽0.3
i.Layer = "tt"
Update
End If
Next

End Sub

 楼主| 发表于 2015-7-4 21:30:22 | 显示全部楼层
so good,现在回头看,判断为pline(line)才用i.Lineweight
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 11:51 , Processed in 0.177465 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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