Set arcpy command line parameter same as Tool parameter

المشرف العام

Administrator
طاقم الإدارة
I have a python script that works correctly when used in a toolbox but not from the command line. How do I duplicate the toolbox magic that happens when specifying a parameter Data Type?

There is GetParameterAsText() but apparently not GetParameterAs('FeatureLayer'), or GetParameterAs('Workspace'), ... in the GetParameter docs.

The parameters as handled in the script:

mxd = arcpy.GetParameterAsText(0) clip_layer = arcpy.GetParameterAsText(1) out_gdb = arcpy.GetParameterAsText(2) In the toolbox I have the 2nd with Data Type set to Feature Layer.



When run from the command line this emits:

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Feature Layer.

...while from the Tool it is:

Executing: clipAllLayers Q:\Current_AOI.mxd Q:\current_aoi.gdb\Converted_Graphics Q:\clipped.gdb
Start Time: Wed Feb 25 10:33:30 2015
Running script clipAllLayers...
layer_one
layer_two
...snip...
Completed script clipAllLayers...
Succeeded at Wed Feb 25 10:33:55 2015 (Elapsed Time: 24.81 seconds)


أكثر...
 
أعلى