hig1824

arcpy.GetArgumentCount() doesn???t count the correct number of arguments passed.

Discussion created by hig1824 on May 2, 2012
Latest reply on May 13, 2012 by lpinner
I have a script that works perfect in python, but isn???t working correctly as a script tool in ArcCatalog.

I have 3 arcpy.GetParameterAsText arguments, two required and one optional.  When I run the script in python it
prints the correct number of arguments.  When I run it in the script tool it prints the count at 3, if I pass 2 or 3.  I
am trying to have it run some steps if the count is 2, and more steps if the count is 3.  The problem is that it returns the
count of 3 every time.

#Get the name and path of the Enterprise Geodatabase
ws = arcpy.GetParameterAsText(0)  #required   In the script tool this parameter is a Workspace
fullPathName = arcpy.GetParameterAsText(1)  #The full path name of the output file geodatabase (required)  In the script tool this parameter is a Workspace
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()
arcpy.AddMessage(pCount)

if pCount == 2:
    do things
else:
    do other things

The add messages shows a count of 3 every time.  If I can't get the GetArgumentCount() to return the correct number of passed arguments, I'm at a loss of what to do.

Outcomes