Below I'm trying to set a Point output parameter. However, right after setting I check the type and it's None. See attachment for GP results. I've also tried GPPoint with no success.
Fundamentally it looks like only certain Types can be used for output parameters, but what others besides scalars are supported? Seems like a simple Point should...
Fundamentally it looks like only certain Types can be used for output parameters, but what others besides scalars are supported? Seems like a simple Point should...
Code:
import arcpy
class Toolbox(object):
def __init__(self):
"""Toolbox definition"""
self.label = "Tools"
self.alias = "Tools"
self.tools = [GetPointTool]
class GetPointTool(object):
def __init__(self):
"""Initialize."""
self.label = "Get me a point"
self.description = ("Returns a simple point")
self.canRunInBackground = True
def getParameterInfo(self):
"""Parameter definitions"""
arcpy_point = arcpy.Parameter(
displayName = "Arcpy point",
name = "arcpyPoint",
datatype = "Point",
# Also tried GPPoint without success
parameterType = "Derived",
direction = "Output")
json_point = arcpy.Parameter(
displayName = "JSON point",
name = "jsonPoint",
datatype = "String",
parameterType = "Derived",
direction = "Output")
return [arcpy_point, json_point]
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
return
def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
def execute(self, parameters, messages):
"""Run the tool"""
# setting parameter[0] to a Point doesn't do anything.
# The type ends up being None in the message (?)
point = arcpy.Point(-111, 42)
parameters[0].value = point
arcpy.AddMessage(type(parameters[0].value))
# json point succeeds cause its String
ptGeom = arcpy.PointGeometry(point)
parameters[1].value = ptGeom.JSON
arcpy.AddMessage(parameters[1].value)
return