在AE中取得所有图层以及没某个图层选择要素的方法 - GIS云中飞鹏

时间:2024-04-15 12:26:34

在AE中取得所有图层以及没某个图层选择要素的方法

在AE中取得所有图层以及没某个图层选择要素的方法
作者:gispower  出处:GIS动力站

1、使用IEnumFeature对象获取map中的FeatureSelection,该方法可以获取所有图层的选择要素

Dim m_pMap as Imap

Set m_pMap=Mapcontrol1.Map

    Dim pEnumFeature As IEnumFeature

    Set pEnumFeature = m_pMap.FeatureSelection

Dim pfeat As IFeature

Set pfeat = pEnumFeature.Next

Do while not pfeat is nothing

       ‘opera

       Set pfeat=pEnumFeature.Next

Loop

 

2、使用ISelectionSetIEnumIDsFeatureClass.GetFeature()方法获取某个图层中的选择要素

Dim lyr2 As IFeatureLayer

Set lyr2 = MapControl1.Layer(1)

Dim selection As IFeatureSelection

Set selection = lyr2

Dim psel As ISelectionSet

Set psel = selection.SelectionSet

Dim lID As Long

Dim pEnumIDs As IEnumIDs

Set pEnumIDs = psel.IDs

Dim s As String

Dim pFeature As IFeature

lID = pEnumIDs.Next

Do

Set pFeature = lyr2.FeatureClass.GetFeature(lID)

‘opera

lID = pEnumIDs.Next

Loop Until lID = -1 \'-1 is returned after last valid ID has been reached