I was recently experimenting with porting some custom editing tools over from .NET to a Python toolbox. At first this was pretty successful and I was pleased with how far I was able to get. However, there is one deal breaker that is preventing us from moving forward with these tools. There is no means in ArcGIS Pro to undo the results of a Python toolbox tool, or a Python script tool.
What I propose is adding the "Enable Undo" functionality available for some geoprocessing tools (e.g., Append) to custom script tools and/or or Python toolboxes. I understand that there any many things that could happen in a Python tool that could not be undone, but if changes are made to the geometry or attributes of a layer or table present in the map, within an edit operation in the script, they should be added to the main undo stack.
Note: apparently there used to be a workaround for this functionality but it is no longer available in 3.x https://community.esri.com/t5/arcgis-pro-questions/how-can-i-enable-quot-undo-edits-quot-for-a-model...
This is implemented in ArcGIS Pro 3.4. Custom script and model tools have the ability to enable undo, and you can add the enable undo toggle using the new Attributes property, "Show Enable Undo Toggle".
With this attribute set, the Enable Undo toggle will display at the bottom of the tool dialog.
Your Python script tool's execution code must use the arcpy.da.Editor class with the editor workspace set to the geodatabase or workspace containing the dataset being edited. When your code calls the editor startEditing function make sure the with_undo argument is set to True or left blank, otherwise the edit will not be able to be undone after the tool runs.
Go to Your Ideas in ArcGIS Pro 3.4 to see other ideas implemented this release and check out the What's New help to learn about everything that is new and improved in ArcGIS Pro 3.4.
If you would like to see an example of the new Enable Undo toggle for script and model tools, and other new features for custom tools added in recent releases, please check out our new blog: Build Better Custom Geoprocessing tools (now with Enable Undo) in ArcGIS Pro!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.