如何得到0层上的所有实体?
-
回答:
主要用到函数说明:
IMxDrawSelectionSet::Select
构造选择集。详细说明如下:
参数 说明 [in] MCAD_McSelect Mode
构造选择集方式
[in] VARIANT point1
构造择择集时需要使用到的点对象
[in] VARIANT point2
构造择择集时需要使用到的点对象
[in,optional] VARIANT filterData
构造选择集的过滤数据
可以取如下值
mcSelectionSetWindow = 0, mcSelectionSetCrossing = 1, mcSelectionSetFence = 2, mcSelectionSetPrevious = 3, mcSelectionSetLast = 4, mcSelectionSetAll = 5, 选择图面上的所有实体 mcSelectionSetWindowPolygon = 6, mcSelectionSetCrossingPolygon = 7, mcSelectionSetUserSelect = 8 mcSelectionImpliedSelectSelect = 9,_I 返回当前图上已经选择的实体
代码实现如下:
'设置过滤条变量 Dim filter As MxDrawResbuf Set filter = New MxDrawResbuf '把图层名"0"作为过滤条件 filter.AddString "0", 8 '定义选择集对象 Dim ss As MxDrawSelectionSet Set ss = New MxDrawSelectionSet '选择图上的所有实体,过滤条为filter ss.Select 5, , , , filter ' 遍历选择集中的实体 Dim i As Integer i = 0 Do While i < ss.Count Dim ent As MxDrawEntity Set ent = ss.Item(i) MsgBox ent.Layer i = i + 1 Loop