How do I add a checkbox that allows the user to only apply tool to selected features?

#Created By: Neal Banerjee
#Date: Novemeber 2013
#Purpose: Calculates multiple fields to a user defined value

#Import modules
import arcgisscripting

#Create the geoprocessor object
gp = arcgisscripting.create(9.3)

#Get Input Fields as User Argument
inFC = gp.GetParameterAsText(0)
inExp = gp.GetParameterAsText(1)
inFldsLst = gp.GetParameterAsText(2)
inFlds = inFldsLst.split(";")

#Iterate through fields and calculate value
for field in inFlds:
  gp.CalculateField_management(inFC, field, inExp)

I am using ArcGIS Desktop 10.4.1.

  • Why are you importing and using arcgisscripting rather than arcpy?
    – PolyGeo
    Dec 8, 2016 at 0:44

1 Answer 1


You should use arcpy instead of argisscripting.

You do not need to add a tick box to apply geoprocessing to selected features. ArcGIS automatically only runs geoprocessing tools on selected features.

If you are trying to override this, you can add another parameter of type 'boolean', which will return true when ticked and false when unticked. Then you would add logic to your code to access the feature class from the source instead of the feature layer in your mxd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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