1

Is it possible to pass the onMouseDownMap X, Y coordinates to a script tool launched using GPToolDialog?

The end goal is to have the user select the add-in tool, click the map to add a point, then pop up the script tool to attribute the point.

class LOMA_Point(object):
"""Implementation for Stormwater_addin.tool (Tool)"""
def __init__(self):
    self.enabled = True
    self.cursor = 3
    self.shape = 'NONE'
def onMouseDownMap(self, x, y, button, shift):
    message = 'Your mouse clicked:' + str(x) + ', ' + str(y)
    pythonaddins.MessageBox(message, 'My Coordinates')
    toolbox = r'Database Management Tools.tbx'
    pythonaddins.GPToolDialog(toolbox, 'AddLOMA')
    pass

1 Answer 1

1

Looking at the pythonaddins page the only 2 parameters used by the GPToolDialog() are the toolbox path and the tool name. There is no mechanism to pass on the XY values.

An alternative approach would be to write the XY values to a well known location such as c:\temp. So your code in the onMouseDownMap event would create a dbase file with 2 fields X and Y and 1 row. Then your tool AddLOMA which I assume is a model can extract these values using the model only Get Field Value tool.

1
  • Thank you for your answer. I ended up dumping the coordinates into a temporary pickle file then had a pyt toolbox tool read the pickle file in the updateParameters function.
    – wBowles
    Feb 23, 2017 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.