I am trying to let a user cancel the ArcToolbox script tool that I am creating. When the code is running, if I press cancel, the process just continues. I have looked at ESRI help on the issue (http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/understanding-cancellation-behavior-in-script-tools.htm) but I cannot get the tool to respond to the cancel command mid run.
I have tried both autoCancelling = true and false with various states of isCancelled both in and out of if statements.
What am I missing?
ArcpMap 10.3 python2.7
This is my attempt to date:
import arcpy, time
from arcpy import env
arcpy.env.autoCancelling = False
if x == 1:
arcpy.AddError('A landbase with this name already exists, you have 10s to cancel otherwise it will be overwritted')
timing = 1
while timing < 11:
time.sleep(1)
arcpy.AddMessage(str(timing))
timing += 1
if arcpy.env.isCancelled == True:
sys.exit()
-
You are referring to ArcGIS Pro documentation when you have an ArcGIS Desktop issue. It may or may not apply so I think you should look for equivalent documentation on the older architecture.PolyGeo– PolyGeo ♦2017年01月13日 22:03:44 +00:00Commented Jan 13, 2017 at 22:03
-
Progress bar usually works for meFelixIP– FelixIP2017年01月14日 00:24:18 +00:00Commented Jan 14, 2017 at 0:24
1 Answer 1
I think @PolyGeo has hit the nail on the head here, you are using 10.3, this is functionality that is only available in 10.4 onward. If you look at the help file here only 10.5 and 10.4 are available under the Other Versions drop down.
Explore related questions
See similar questions with these tags.