Can I select a new feature in a feature class before saving the change?

698
2
03-18-2014 12:15 PM
KerryAlley
Occasional Contributor
Hello,

I have a VB.NET addin button that activates the ArcMap "split command" for the user and then updates the attributes of the resulting arcs.  I would like to make another button that is almost identical, but using the "split tool" instead of the "split command".  However, the new arc is not selected after the split tool executes, so I am unable to update its attributes.  I would like to add the new arc to the selection set, possibly by referring to its OBJECTID.  I know that the OBJECTID of the new arc is the largest one in the edited (unsaved) version of the feature class, but if I reference the feature class via its layer in ArcMap, I will only see the pre-edited version (without the new feature).  Any suggestions how I can get around this issue?

Thanks!
Kerry
0 Kudos
2 Replies
KerryAlley
Occasional Contributor
Some other observations relevant to the issue in my previous post:

I�??m not observing this �??blindness�?� to previous edits with other tools I�??ve developed, even when the edits involve creating new features.  For example, successive edits with my tool based on the Split Command are aware of the incrementing value of a field representing a unique ID, but maybe that is because each new feature and its new attribute values is stored using the IFeature.store() method before another new feature is added?  Maybe there is something different with the OBJECTID field?  Or with how the Split Tool stores its features? 

Puzzled as usual,
Kerry
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
Hello,

I have a VB.NET addin button that activates the ArcMap "split command" for the user and then updates the attributes of the resulting arcs.  I would like to make another button that is almost identical, but using the "split tool" instead of the "split command".  However, the new arc is not selected after the split tool executes, so I am unable to update its attributes.  I would like to add the new arc to the selection set, possibly by referring to its OBJECTID.  I know that the OBJECTID of the new arc is the largest one in the edited (unsaved) version of the feature class, but if I reference the feature class via its layer in ArcMap, I will only see the pre-edited version (without the new feature).  Any suggestions how I can get around this issue?

Thanks!
Kerry


You can get the new feature by listening on Editor events
                UID editorUid = new UID();
                editorUid.Value = "esriEditor.Editor";
                IEditor3 m_editor = ArcMap.Application.FindExtensionByCLSID(editorUid) as IEditor3;
                m_editEvents = m_editor as IEditEvents_Event;
                //To get the original feature
               // m_editEvents.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(m_editEvents_OnChangeFeature);
               //Get the new feature
                m_editEvents.OnCreateFeature += new IEditEvents_OnCreateFeatureEventHandler(m_editEvents_OnCreateFeature); 

In OnCreateFeature  event handler you can add your new arc to the selection

      
 void m_editEvents_OnCreateFeature(IObject obj)
        {
            IFeatureSelection pFeatSel = arcFeatureLayer as IFeatureSelection;
            pFeatSel.Add(obj as IFeature);
            ArcMap.Document.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); 
        }
0 Kudos