Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Create Point FC from Mouse Click Event

$
0
0
I'm starting to learn the Python Add-in starting with some simple code. This bit attempts to capture XY of mouse click event and write it to a point feature. The message box displays the XY but nothing else seems to be working. Can anyone show me what'sw wrong?



Code:

import arcpy
from arcpy import env
import pythonaddins

class ToolClass2(object):
    """Implementation for ArcGISAddins_addin.tool (Tool)"""
    message = "Your mouse clicked:"
    def __init__(self):
        self.enabled = True
        self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
    def onMouseDownMap(self, x, y, button, shift):
        message = "Your mouse clicked:" + str(x) + ", " + str(y)
        pythonaddins.MessageBox(message, "My Coordinates")
       
        env.outputCoordinateSystem = r"Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
       
        point = arcpy.Point(x, y)
        pointGeometry = arcpy.PointGeometry(point)
        """ Create a copy of the PointGeometry objects, by using pointGeometry  """
        """  as input to the CopyFeatures tool. """
arcpy.CopyFeatures_management(pointGeometry, "c:/temp/test.gdb/points")


Viewing all articles
Browse latest Browse all 2485

Trending Articles