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()
  • 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 Jan 13 '17 at 22:03
  • Progress bar usually works for me – FelixIP Jan 14 '17 at 0:24
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.

  • so, how do I let the user cancel? – D_C Jan 16 '17 at 17:13
  • Not sure you can, happy to be proven wrong! – Hornbydd Jan 16 '17 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.