How can I enable "Undo Edits" for a Model?

506
7
Jump to solution
10-13-2020 04:20 PM
JoshuaLogsdon1
New Contributor II

I have a small model that only runs Calculate Field (Data Management) which I would like to have the option Enable Undo. I'm not able to undo edits when running this model, even when enabling an Edit Session manually. I can only undo edits if I have already altered a feature or record in the current session.

ArcGIS Pro 2.6.2

Windows 10 x64Example cannot undo edits

0 Kudos
1 Solution

Accepted Solutions
DrewFlater
Esri Contributor

At this time, as of ArcGIS Pro 2.6, there is not a user interface to allow a custom tool to show the undo toggle. We maintain a hardcoded list of system tools which have been tested to ensure the complete operation can be registered with an edit session and cleanly undone using undo/redo/save/discard buttons. Since there is no guarantee that a custom tool meets the same requirements (your code or model can literally do anything) we haven't made it possible for a custom tool to expose the Enable Undo feature.

I can provide an unsupported and "use at your own risk" workaround for your specific tool and machine which you can give a try. 

1. Find the file C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Toolboxes\editsession.txt and edit in a text editor

2. Add a new line at the bottom with <yourtoolboxalias>.<yourtoolname> 

3. Save and close the file.

4. Save and close Pro

5. Reopen Pro and open the tool to see the Undo toggle at the bottom next to the Run button.

here is the format your toolbox.tool entry should take:

(my toolbox alias is LASiteSelection, and the model name is Model1)

View solution in original post

7 Replies
DanPatterson
MVP Honored Contributor

why not implement the model as a tool (python script, conventional tool would be the easiest to implement)


... sort of retired...
JoshuaLogsdon1
New Contributor II

Would a python script allow me to undo edits after running? I was considering this, but I couldn't find anything in the tool syntax. Is this some environmental variable maybe?

0 Kudos
DrewFlater
Esri Contributor

At this time, as of ArcGIS Pro 2.6, there is not a user interface to allow a custom tool to show the undo toggle. We maintain a hardcoded list of system tools which have been tested to ensure the complete operation can be registered with an edit session and cleanly undone using undo/redo/save/discard buttons. Since there is no guarantee that a custom tool meets the same requirements (your code or model can literally do anything) we haven't made it possible for a custom tool to expose the Enable Undo feature.

I can provide an unsupported and "use at your own risk" workaround for your specific tool and machine which you can give a try. 

1. Find the file C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Toolboxes\editsession.txt and edit in a text editor

2. Add a new line at the bottom with <yourtoolboxalias>.<yourtoolname> 

3. Save and close the file.

4. Save and close Pro

5. Reopen Pro and open the tool to see the Undo toggle at the bottom next to the Run button.

here is the format your toolbox.tool entry should take:

(my toolbox alias is LASiteSelection, and the model name is Model1)

View solution in original post

DanPatterson
MVP Honored Contributor

Very nice!


... sort of retired...
JoshuaLogsdon1
New Contributor II

Oh very interesting! I'll give this a try. I appreciate the in-depth explanation and solution!

0 Kudos
JoshuaLogsdon1
New Contributor II

Finally implemented this and it is doing exactly what I wanted!

Small observation: The Undo command does not undo the entire Model's operation in a single click. Each click will undo the last tool that successfully ran in the Model.

Ex: I had two Calculate Field tools run in my model. I had to use the Undo command twice to revert to the original state.

There's no problem with this, some food for thought for anyone who finds this post.

Thanks again

0 Kudos
Robert_LeClair
Esri Frequent Contributor

VERY interesting workaround!  And I like seeing the list of GP tools in the *.txt file that has the Undo tab ability.  Interesting...