I am displaying points, lines and polygons on ArcMap as features with an addin. I want my end users to be able to change features (move geometries, add vertex, delete vertex etc) and get the updated feature's geometry.

For this purpose, I subscribe to OnChangeFeauture event with the following piece of code:

IEditEvents_Event editEvent = (IEditEvents_Event)ArcMap.Editor;
editEvent.OnChangeFeature += OnChangeFeature;

OnChangeFeauture event is fired only if a feature is moved. For points, this is fine, but for lines and polygon an edit doesn't necessarily mean the geometry needs to move (dragged somewhere else).

I subscribed to OnVertexMoved hoping to receive events if a vertex of line or polygon is moved.

((IEditEvents2_Event)Map.Editor).OnVertexMoved += OnVertexMoved;

UPDATE OnVertexMoved event DID work. It has a reference to the vertex as an IPoint object, which is fine. But when I checked ShapeCopy property of the selected feature (when that event is fired), it was not updated at all. So when should I expect to get ShapeCopy updated in an edit session unless it is moved explicitly?

Otherwise, I had to ask users to drag geometry as a whole a little bit even if they move just a vertex (to get their updated geometry). That doesn't make sense at all.

  • Are the edits being done with something like the parcel fabric editor extension? gis.stackexchange.com/questions/83167/… – Jay Cummins Mar 10 '16 at 21:16
  • It might be a bug. I have looked through some old code that responds to edit events (changing attributes, to make sure they're conforming in shapefiles) and the OnChangeFeature works as it says on the box. Note that OnCreateFeature and OnDeleteFeature also need to be handled as they don't fire the OnChangeFeature event... is the event fired when an attribute is changed? If you're looking for changed geometries and not attributes then perhaps the OnSketchFinished event might help. – Michael Stimson Mar 10 '16 at 21:18
  • @JayCummins yes. – mert Mar 10 '16 at 21:24
  • @MichaelMiles-Stimson I am not dealing with attribute update, so I tried OnSketchFinished, but it didn't fire at all. I updated the question, please take a look. – mert Mar 10 '16 at 21:39
  • If it's in a parcel fabric as you say then this is a duplicate of the question @JayCummins indicated. – Michael Stimson Mar 10 '16 at 22:02

You need to cast obj to IRowChanges and loop to find what changed.

IRowChanges prowchange = obj as IRowChanges; 
for (int i = 0; i < obj.Fields.FieldCount; i++) {
  if (prowchange.get_ValueChanged(i) == true) {
    //Custom code here, this is the row that changed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.