GetArgumentCount (arcpy)
サマリ
Returns the number of arguments passed to the script.
構文
GetArgumentCount ()
データ タイプ | 説明 |
Integer |
The number of arguments passed to the script. |
コードのサンプル
GetArgumentCount example
Check for required number of arguments to run Clip tool and handle optional argument.
import sys
import arcpy
# Set workspace
arcpy.env.workspace = "c:/data/airport.gdb"
# Set local variables
in_features = arcpy.GetParameterAsText(0)
clip_features = arcpy.GetParameterAsText(1)
out_feature_class = arcpy.GetParameterAsText(2)
xy_tolerance = arcpy.GetParameterAsText(3)
# Check for required number of arguments
if arcpy.GetArgumentCount() < 3:
print("3 arguments required for Clip_analysis tool")
# Execute Clip tool
try:
arcpy.Clip_analysis(in_features, clip_features,
out_feature_class, xy_tolerance)
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
関連トピック
4/26/2014