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

2764
9
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 Regular 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

9 Replies
DanPatterson
MVP Esteemed 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 Regular 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)

DanPatterson
MVP Esteemed 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
ArcProOne
New Contributor II

I don't seem to have the editsession.txt file in Pro 2.9.0, do you know if it moved somewhere?  Or is there a better way to do this now?

0 Kudos
EstherSmith_Dev
New Contributor III

Hi,

I do not see this C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Toolboxes\editsession.txt file in ArcGIS Pro 2.9.6. Is that door/hack now closed?

I have a python toolbox (.PYT) and one of the tool selects some assets based on the criteria and updates an attribute for selection using arcpy.CalculateField. Even though the dataset is branch versioned layer, I do not see Save/Discard options meaning the updates are saved already. I would like to provide user with Save/Discard option. When I launch CalculateField tool from the Data Management toolbox, I see "Enable Undo" toggle at the bottom.

EstherSmith_Dev_0-1683729421645.png

How do I reproduce this in my python toolbox?

Thanks,

 

 

  

0 Kudos
Robert_LeClair
Esri Notable Contributor

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