1

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()
asked Jan 13, 2017 at 21:59
2
  • 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. Commented Jan 13, 2017 at 22:03
  • Progress bar usually works for me Commented Jan 14, 2017 at 0:24

1 Answer 1

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.

answered Jan 14, 2017 at 1:25
2
  • so, how do I let the user cancel? Commented Jan 16, 2017 at 17:13
  • Not sure you can, happy to be proven wrong! Commented Jan 16, 2017 at 18:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.