armylee 发表于 2005-5-13 02:10:00

怎样判断一个实体是不是在选择集里?

rt

evaporated 发表于 2005-5-13 08:52:00

可能要穷举。
不知道是不是个好办法。
例如
dim a as acadEntity
dim s as acadSelectionset
set s="..."
For each Item in s
                         if a=item then msgbox "找到该实体"
Next
请大虾指教:能够直接实体间 用 a=item 么?

cbse_smy 发表于 2005-5-13 09:13:00

除非象在C中先将"="重载,否则不能用=

雪山飞狐_lzh 发表于 2005-5-13 10:05:00

Sub tt()
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("Test").Delete
Set ss = ThisDrawing.SelectionSets.Add("Test")
ss.Select acSelectionSetAll
Dim a As AcadEntity, i As AcadEntity
Set a = ThisDrawing.ModelSpace(0)
For Each i In ss
If i Is a Then
MsgBox "OK"
Exit For
End If
Next i
End Sub

armylee 发表于 2005-5-13 11:17:00

没有再简洁的方法了吗?
最好用一句语句来判断。

zfbj 发表于 2005-5-13 13:26:00

4楼已经很简洁,没有捷径,你可以把那些代码封装成一个函数。

cbse_smy 发表于 2005-5-13 15:08:00

可以遍历选择集,然后对比ID号进行判别!

armylee 发表于 2005-5-13 15:47:00

谢谢各位提供这么多种方法。

gby7273 发表于 2005-5-14 21:21:00

终于找到二次开发的地方啦!小弟新来,大家多关照!
页: [1]
查看完整版本: 怎样判断一个实体是不是在选择集里?