Control license behavior

The isLicensed method is an optional method that can be used to check if a script tool is licensed to execute. It can be used to restrict the tool from being run if the appropriate licenses and extensions required to run other geoprocessing tools used by the script tool are not available.

Wenn die isLicensed-Methode False zurückgibt, kann das Werkzeug nicht ausgeführt werden. Wenn die Methode True zurückgibt oder nicht verwendet wird, kann das Werkzeug ausgeführt werden.

def isLicensed(self):
    """Allow the tool to execute, only if the Erweiterung "ArcGIS 3D Analyst" 
    is available."""
    try:
        if arcpy.CheckExtension("3D") != "Available":
            raise Exception
    except Exception:
        return False  # tool cannot be executed

    return True  # tool can be executed

Verwandte Themen