litName = arcpy.GetParameterAsText(2) #Optional The three letter code for records in a field. In the script tool this parameter is a String pCount = arcpy.GetArgumentCount() if pCount == 2 or not litName: do things else: do other things
Optional parameters are passed as a # character so that place counting is preserved.So you could test for the value being == '#' to see if it was not set.
import sys,arcpy for i,arg in enumerate(sys.argv[1:]): arcpy.AddMessage("argv %s=%s"%(i,repr(arg))) arcpy.AddMessage("param %s=%s"%(i,repr(arcpy.GetParameterAsText(i))))
Executing: Script Layer1 # # Start Time: Mon May 14 12:33:51 2012 Running script Script... argv 0='Layer1' param 0=u'Layer1' argv 1='#' param 1='' argv 2='#' param 2='' Completed script Script... Succeeded at Mon May 14 12:33:52 2012 (Elapsed Time: 1.00 seconds)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.