PROBLEM

Unable to rotate features after programmatically selecting them

Last Published: April 25, 2020

Description

Selecting features in an edit session using the Select Features Tool or the Edit Tool activates the Rotate Tool on the Editor Toolbar, enabling the rotation of selected features. When the selection is made programmatically within an edit session the Rotate Tool activates, but features fail to rotate.

Cause

The ISelectionEvents::SelectionChanged event must be fired before the rotate tool is fully activated. The editor relies on the SelectionChanged event to union feature selection geometries, and set the selection anchor. If this event is not physically fired there will be no unioned geometry to rotate and there will not be an anchor location.

Solution or Workaround

The following code sample demonstrates how to fire the ISelectionEvents::SelectionChanged event.

Code:
Sub SelectionChanged()

Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pLayer As IFeatureLayer
Dim pFc As IFeatureClass
Dim pSelSet As ISelectionSet
Dim pFSel As IFeatureSelection
Dim pSelEvents As ISelectionEvents

Set pDoc = ThisDocument
Set pMap = pDoc.FocusMap
Set pLayer = pMap.Layer(0)
Set pFc = pLayer.FeatureClass

'Get the selection set
Set pSelSet = pFc.Select(Nothing, 1, 1, Nothing)

'Update the layer with the seletion set
Set pFSel = pLayer
Set pFSel.SelectionSet = pSelSet

'Fire SelectionChanged event
Set pSelEvents = pMap
pSelEvents.SelectionChanged

'Refresh
pDoc.ActiveView.Refresh

End Sub

    Article ID: 000007130

    Software:
    • ArcMap

    Receive notifications and find solutions for new or common issues

    Get summarized answers and video solutions from our new AI chatbot.

    Download the Esri Support App

    Discover more on this topic

    Get help from ArcGIS experts

    Contact technical support

    Download the Esri Support App

    Go to download options