Select to view content in your preferred language

OnStartEditing equivalent

1296
3
Jump to solution
02-16-2023 03:30 PM
GaryBilotta
Regular Contributor

This has been discussed in an older post from years ago, but there really wasn't an answer as far as I can tell. I am trying to port over an ArcObjects extension which listens for OnStartEditing and OnStopEditing.  When an edit session begins, many checks happen including figuring out the layers in the map, pulling data from the database, and if the appropriate datastores are connected to specific layers - all for the purpose of triggering certain things through the edit session.  Having the ability to know when to begin listening for all these things would be super helpful with an OnStartEditing event listener.  

The previous post mentioned listening for a custom tool activation event, but what happens if a user edits a geometry without activating the tool?  The extension I am porting over listens for geometry changes too in which an OnStartEditing event listener would be able to prepare for.

One possibility I am thinking through is to listen for the esri_editing_editingCurrently and esri_editing_editingNotAvailable states.  If I could be notified of these states being in the ArcPro session, I could use them like the OnStartEditing and OnStopEditing events.  The issue is, I'm not sure exactly where to check if these states are in the current ArcPro session.  Is there an event to subscribe to in which I can check for these states continuously?

The use of 'Project.Current.IsEditingEnabled' could be used too, but where can I continuously check to see if the value of this has changed?

OnDrawComplete seems to be a possibility as staff generally zoom in/out and pan as they edit, but there is no guarantee the map will redraw before attempting an edit of some sort whether tabular or shape.

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

One of the differences between ArcGIS Desktop and ArcGIS Pro is that in ArcGIS Pro Editing is in essence always on, whereas in ArcGIS Desktop you had to start/stop editing.  Consequently, if you have an add-in that customizes editing you have to do your house keeping when the project (or map) is loaded.  If you want to have better control over edits you could use ArcGIS Pro's capability to 'Enable and Disable Edits' (see ProConcepts Editing · Esri/arcgis-pro-sdk Wiki (github.com)) and perform your house keeping in the code behind for the 'Enable/Disable Edits' button.  In order to do so you would need to create your own 'Start/Stop Edit' button that calls the ArcGIS Pro API to enable/disable Pro's editing and also calls your house keeping code.  You can change ArcGIS Pro's Backstage options programmatically using this API: EditingOptions Property—ArcGIS Pro 

You can also check out this sample: arcgis-pro-sdk-community-samples/Editing/DemoUseSelection at 6078006a3943364f2a7931b19d1eb03c8a99e1c...

it shows how to enable / disable editing in Pro.

 

 

 

View solution in original post

0 Kudos
3 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

One of the differences between ArcGIS Desktop and ArcGIS Pro is that in ArcGIS Pro Editing is in essence always on, whereas in ArcGIS Desktop you had to start/stop editing.  Consequently, if you have an add-in that customizes editing you have to do your house keeping when the project (or map) is loaded.  If you want to have better control over edits you could use ArcGIS Pro's capability to 'Enable and Disable Edits' (see ProConcepts Editing · Esri/arcgis-pro-sdk Wiki (github.com)) and perform your house keeping in the code behind for the 'Enable/Disable Edits' button.  In order to do so you would need to create your own 'Start/Stop Edit' button that calls the ArcGIS Pro API to enable/disable Pro's editing and also calls your house keeping code.  You can change ArcGIS Pro's Backstage options programmatically using this API: EditingOptions Property—ArcGIS Pro 

You can also check out this sample: arcgis-pro-sdk-community-samples/Editing/DemoUseSelection at 6078006a3943364f2a7931b19d1eb03c8a99e1c...

it shows how to enable / disable editing in Pro.

 

 

 

0 Kudos
EricPfirman
Occasional Contributor

Don't you have to hit the Edit button on the Edit tab to start an editing session? I am looking for an event I can subscribe to that fires when that button is pressed. Then I can enable or disable the appropriate editing buttons in my add-in.

GaryBilotta
Regular Contributor

That is quite frustrating the always on editing.  I am enforcing the use of the 'Enable and Disable Edits' button within the add-in's On Project Load event.  Definitely someone could disable it very easily once the project is loaded; but hopefully they will not - makes me think to probably check that setting during other events too.  I'll definitely have a look at the sample in the link for creating my own start/stop editing button - very good idea.  Thank you so much.

0 Kudos