Satisfy Python Script Tool required parameter with optional boolean

المشرف العام

Administrator
طاقم الإدارة
I'm using ArcGIS for Desktop 10.3.0.4322

This seems like it would have a fairly simple answer but have been unable to figure it out myself. I have a script tool which requires a parameter (folder path to a gdB, via GetParameterAsText) so that a later process can be saved there. The thing I want to do is make an Optional Boolean parameter, that when checked, automatically fills in the folder path gdB parameter. The parameter text asks the user, "Use default workspace?", to which if they check the box (boolean == 'true'), then the folder path parameter will be automatically defaulted (saving the user a small amount of time). I have already created the boolean parameter in the script tool, I am however unaware of how to "fill in" the required parameter based on the user's boolean. Any help is greatly appreciated, thank you!

Code Snippet:

# Ask user to select the Geodatabase workspace to use for data outputuserWorkspace = arcpy.GetParameterAsText(0)# Ask user if they want to use default workspace (boolean)useDefault = arcpy.GetParameterAsText(1)# If user wants default workspace, then give it to the required parameter (0)if useDefault == 'true': arcpy.env.workspace = path else: # Set workspace environment based upon user's choice arcpy.env.workspace = userWorkspace

أكثر...
 
أعلى