I would like to know if it is possible to get the coordinates from a user clicked point in the current map document - arcpy.mapping.MapDocument("CURRENT")?

I am using ArcGIS Desktop 10.0.


There is an Esri How To: Capture map coordinates with a mouse click using Python with code. This also mentions that:

"Prior to ArcGIS 10.1, Python could not be used to interact with the ArcGIS interface."

I have tried that code but I have not been able to get the button I have the code behind to activate so I cannot yet confirm that the code works. I am using ArcGIS Desktop 10.1 SP1.

My code for your reference is:

import arcpy
import pythonaddins

class ClickForXYCoordinates(object):
    """Implementation for MyPythonAddIn_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.shape = "NONE"
    def onMouseDownMap(self, x, y, button, shift):
        message = "Your mouse clicked:" + str(x) + ", " + str(y)
        pythonaddins.MessageBox(message, "My Coordinates") 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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