ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Hilfe
  • Sign Out
ArcGIS Desktop

ArcGIS Online

Die Mapping-Plattform für Ihre Organisation

ArcGIS Desktop

Ein vollständiges professionelles GIS

ArcGIS Enterprise

GIS in Ihrem Unternehmen

ArcGIS Developers

Werkzeuge zum Erstellen standortbezogener Apps

ArcGIS Solutions

Kostenlose Karten- und App-Vorlagen für Ihre Branche

ArcGIS Marketplace

Rufen Sie Apps und Daten für Ihre Organisation ab.

  • Dokumentation
  • Support
Esri
  • Anmelden
user
  • Eigenes Profil
  • Abmelden

ArcMap

  • Startseite
  • Erste Schritte
  • Karte
  • Analysieren
  • Verwalten von Daten
  • Werkzeuge
  • Erweiterungen

GetArgumentCount

  • Zusammenfassung
  • Syntax
  • Codebeispiel

Zusammenfassung

Returns the number of arguments passed to the script.

Syntax

GetArgumentCount ()

Rückgabewert

DatentypErklärung
Integer

The number of arguments passed to the script.

Codebeispiel

GetArgumentCount example 1

Check for required number of arguments to run the Clip tool and handle optional argument.

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))
GetArgumentCode example 2

The following sample uses the GetArgumentCount and GetParameterAsText functions to assign all parameter values in a script tool to a single variable as a list of values.

import arcpy

args = [arcpy.GetParameterAsText(i) for i in range(arcpy.GetArgumentCount())]

Verwandte Themen

  • CopyParameter
  • GetParameter
  • GetParameterAsText
  • GetParameterCount
  • GetParameterInfo
  • GetParameterValue
  • SetParameter
  • SetParameterAsText
  • Festlegen von Parametern für Skriptwerkzeuge

ArcGIS Desktop

  • Startseite
  • Dokumentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

Über Esri

  • Über uns
  • Karriere
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Wir sind an Ihrer Meinung interessiert.
Copyright © 2021 Esri. | Datenschutz | Rechtliches