Select to view content in your preferred language

Performing additional actions after pythonaddins.GPToolDialog() is called

2168
1
10-18-2013 09:18 AM
TimHopper
Frequent Contributor
ArcGIS 10.1

Let's say I have a python addin with a single tool.  The tool creates a new in_memory point feature class with a single point when the onMouseDownMap event occurs.  It then utilizes pythonaddins.GPToolDialog to launch the buffer tool.  The buffer tool uses the in_memory point feature as the input and then deletes it and removes it from the map when the tool finished.

This all works fine if the GP tool is completed successfully.  However, if the user chooses "Cancel" on the GP tool dialog, the tool quits but the in_memory point feature class that was created initially still remains in the TOC.

Anybody have a good workflow to remove that in_memory feature class from the map if the GP tool is cancelled instead of completed??
Tags (2)
0 Kudos
1 Reply
JohnDye
Deactivated User
There's no way that I can think of off the top of my head for an addin to monitor a GPTool. The Addin can call it, but once the tool is called, the GPTool is not reporting anything back to the environment that you can really act on.

You could just program the buffer into the addin with arcpy.Buffer_analysis though. If you want the user to be able to set the buffer parameters themselves, you could just use comboboxes to allow them to enter the values/parameter choices, then pass those values into the arcpy.Buffer_analysis

If you're really stuck on doing it by calling the GPToolDialog, the only other way I could think of doing something like this would be to instead delete the point whenever the dataframe extent changes. This wouldn't delete the point as soon as the tool was cancelled, but as soon as you panned or zoomed, resulting in a different extent, it would.
0 Kudos