AnsweredAssumed Answered

ArcPy script in toolbox - what do I do about optional parameters?

Question asked by rosie_bell on Aug 20, 2012
Latest reply on Sep 27, 2012 by rosie_bell
I made my first Python tool this week, a Search by Attribute tool to search our cadastre. When I have required parameters it works beautifully. As soon as I make the parameters optional, it doesn't return any results (even if I complete all the fields).

What am I doing wrong? I added the 'if' line after reading another thread about optional parameters, but it doesn't make any difference with this problem. Thanks.

#define user parameter for road name, and locality  SelCondition = arcpy.GetParameterAsText(0) if (not SelCondition) or (SelCondition == "#") or (len(SelCondition.strip()) == 0):     SelCondition = ""   LocalityName = arcpy.GetParameterAsText(1) if (not LocalityName) or (LocalityName == "#") or (len(LocalityName.strip()) == 0):     LocalityName = ""   # select cadastral lots on road name and locality, and lot no arcpy.SelectLayerByAttribute_management("Cadastre","NEW_SELECTION", "\"ROAD_NAME\" = "+SelCondition)  arcpy.SelectLayerByAttribute_management("Cadastre","SUBSET_SELECTION", "\"LOCALITY\" = "+LocalityName)