Hello,
I try to explain the problem:
I have a tool within a parameter (string) of a Value List with 4 values â??â??has (4 different coordinate systems).
The tool itself is relatively simple:
Input file: File
Output file: shapefile
Edition KS: String (4 different KS to choose)("DHDN Soldner Berlin", "GCS_WGS_1984", "WGS 1984 auxiliary sphere", "ETRS 1989)
Function: Project
my filter.list:
self.params[2].filter.list = ["DHDN Soldner Berlin", "GCS_WGS_1984", "WGS 1984 auxiliary sphere", "ETRS 1989 ] if self.params[2].filter.list[0] == "DHDN Soldner Berlin": arcpy.Project_management(input_shp, new_shp, "C:\Users\\hicham\\MEINE_DATEN\\koordinates\\DHDN Soldner Berlin.prj"") elif self.params[2].filter.list[1] == "WGS 1984": arcpy.Project_management(input_shp, new_shp, "C:\Users\\hicham\\MEINE_DATEN\\koordinates\\GCS_WGS_1984.prj") elif self.params[2].filter.list[1] == "WGS 1984 auxiliary sphere": arcpy.Project_management(input_shp, new_shp, "C:\Users\\hicham\\MEINE_DATEN\\koordinates\\WGS 1984 Web Mercator (auxiliary sphere).prj") elif self.params[2].filter.list[1] == "ETRS 1989": arcpy.arcpy.Project_management(input_shp, new_shp, "C:\Users\\hicham\\MEINE_DATEN\\koordinates\\ETRS 1989 UTM Zone 33N 7stellen.prj") return
I just do not know what function I would have to enter in the validation to be able to select these values â??â??from the list in order to accurately transform the file into a specific KS (eg. Soldner Berlin) can.
Would be great if someone could help me.
Thanks in advance!:)
Hicham
Looking your look it appears that you're wanting to create a project tool specifically for shapefiles where your users are presented with your list of specific coordinate systems. I would think that you'd only need the tool validator for the second parameter, which would populate the input coordinate system name based on the shapefile chosen by the user.
import arcpy class ToolValidator(object): """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog.""" def __init__(self): """Setup arcpy and the list of tool parameters.""" self.params = arcpy.GetParameterInfo() def initializeParameters(self): """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" return def updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" if self.params[0].altered: sRef = arcpy.Describe(self.params[0].value.value).spatialReference self.params[1].value = sRef.PCSName if sRef.PCSName not in ("", " ") else sRef.GCSName return def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return
The third parameter would be a list and you could specify the values using the tool's UI as you showed in the Werteliste.JPG.
The actual work of the tool would need to take place in the script being called by the tool. You wouldn't want to execute this in the tool validator. You would need to use the needed logic to convert the name of the coordinate system the user selected into a valid system for the project tool.