ArcPro python toolbox script with user selected coordinate system parameter errors when passing in parameter

Viewed 19

I am creating a tool with ArcPro 2.9 so a user can project feature classes in a file geodatabase by selecting their preferred coordinate system. I can assure all data are valid feature classes.

I have tried passing in the parameter with parameters[0].value and get these errors... ERROR 000840: The value is not a Feature Class. ERROR 000840: The value is not a Feature Dataset. ERROR 000840: The value is not a File. ERROR 000735: Output Coordinate System: Value is required Failed to execute (Project).

parameters[0].valueAsText give me these errors... ERROR 000354: The name contains invalid characters ERROR 000735: Output Coordinate System: Value is required Failed to execute (Project).

Is there a specific 'value' for coordinate systems? What am I missing?

import arcpy, os

arcpy.env.overwriteOutput = 1

class Toolbox(object):
    def __init__(self):
        self.label = "Pro_Data_Extract"
        self.alias = ""

class Extract(object):
    def __init__(self):
        self.label = "Extract"
        self.description = "The data extract tool will clip all datasets to the visual extent of the main map."
        self.canRunInBackground = False

    def getParameterInfo(self):
        param0 = arcpy.Parameter(
        name="GPSpatialReference",
        displayName="Projected Coordinate System",
        datatype="GPCoordinateSystem",
        parameterType="Required",
        direction="Input")

        params = [param0]#, param1]#, param2]
        return params

    def isLicensed(self):
        return True

    def updateParameters(self, parameters):
        return

    def updateMessages(self, parameters):
        return

    def execute(self, parameters, messages):
        gdb_loc = r'D:\JJ_Development\BasemapData_Automation\Pro_Data_Extract\test842.gdb'
        crs = parameters[0].value
        # ERROR 000840: The value is not a Feature Class.
        # ERROR 000840: The value is not a Feature Dataset.
        # ERROR 000840: The value is not a File.
        # ERROR 000735: Output Coordinate System: Value is required
        # Failed to execute (Project).
        # Failed to execute (Extract).

        crs = parameters[0].valueAsText
        # ERROR 000354: The name contains invalid characters
        # ERROR 000735: Output Coordinate System: Value is required
        # Failed to execute (Project).
        # Failed to execute (Extract).

        #********DATA AND PATHS********
        aprxMap = arcpy.mp.ArcGISProject("CURRENT")
        
        aoi = os.path.join(gdb_loc, 'AOI')
     
        for map in aprxMap.listMaps():
            for lyrs in map.listLayers():
                arcpy.Project_management(lyrs, crs)

        return
0 Answers
Related