Hi,
I build a new geoprocessing tool, and I want to set a default outputCoordinateSystem in Environment:
I found we have it tool parameters:
I tried to use initializeParameters:
class ToolValidator:
# Class to add custom behavior and properties to the tool and tool parameters.
def __init__(self):
# Set self.params for use in other validation methods.
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
# Customize parameter properties. This method gets called when the
# tool is opened.
for param in self.params:
if param.name == "outputCoordinateSystem":
param.value = arcpy.SpatialReference(2230)
return
but it didn't work out.
Could you, please, help me?
Your parameter name is the Name field. that is not 'outputCoordinateSystem' in your screenshot, but 'output_feature...'
You can also just manually set the environment variable using arcpy.env:
import arcpy
...
def main():
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(2230)
...