I created this short script to switch selectionset for all layers in one map. It may have no generic value, but it does demonstrate the selectionset interface.
Sub SwitchSelection()
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pLayer As ILayer
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.ActiveView
Dim pFLayer As IFeatureLayer
Dim pEnumLayer As IEnumLayer
Set pEnumLayer = pMap.Layers
Set pLayer = pEnumLayer.Next
Do While Not pLayer Is Nothing
If TypeOf pLayer Is IFeatureLayer Then
Set pFLayer = pLayer
Dim pFSel As IFeatureSelection
Set pFSel = pFLayer
Dim pSelFeats As ISelectionSet
Set pSelFeats = pFSel.SelectionSet
Dim pAllFeats As ISelectionSet
Set pAllFeats = pFLayer.FeatureClass.Select(Nothing, esriSelectionTypeIDSet, esriSelectionOptionNormal, Nothing)
Dim pNewSel As ISelectionSet
pAllFeats.Combine pSelFeats, esriSetDifference, pNewSel
Set pFSel.SelectionSet = pNewSel
End If
Set pLayer = pEnumLayer.Next
Loop
pMxDoc.ActiveView.Refresh
Monday, February 18, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment