How to get mouse click coordinates in ArcPy?

How to get mouse click coordinates in ArcPy?

You can get the coordinates a mouse click via the onMouseDownMap() function of the Tool Class for Python add-ins. The x and y values for onMouseDownMap and onMouseUpMap represent the map coordinates where the button was pressed or released.

How to capture map coordinates with mouse click?

The function ‘onMouseDownMap’ passes the map’s coordinates to the add-in. Delete all the other functions (def). self.shape = “NONE” # Can set to “Line”, “Circle” or “Rectangle” for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.

How do you get the coordinates of a map in Python?

Open the Python script that is generated for the add-in and find the tool class that was added in Step 1. The function ‘onMouseDownMap’ passes the map’s coordinates to the add-in. Delete all the other functions (def).

How to save a MXD file in ArcGIS?

The following script creates a separate MXD file for each data frame in a map document. The output map documents will be saved in data view mode so when each map document is opened, the corresponding data frame will be active data frame. The script also sets the title property of each output map document.

Where do I find the mapdocument object in ArcGIS?

The MapDocument object provides access to most of the map document properties found in the Map Document Properties dialog box in ArcMap ( File > Map Document Properties ). The object also contains methods for managing map document thumbnails and methods for saving map documents that are found within the ArcMap File menu.

How to delete arcpy.mapping.listlayers ( MXD )?

>>> mxd = arcpy.mapping.MapDocument (“CURRENT”) for lyr in arcpy.mapping.ListLayers (mxd): print lyr.name del mxd The following script will allow secured layers to render correctly by creating an SDE connection in memory before opening a map document that requires password information.

How to add a map to a Python toolbar?

Install the Python Add-in Wizard and start a project. Go through the wizard to create a new toolbar and a subsequent new tool. Open the Python script that is generated for the add-in and find the tool class that was added in Step 1. The function ‘onMouseDownMap’ passes the map’s coordinates to the add-in.