Something similar to this.
import arcpy
import pythonaddins
import os
from arcpy import env
class AddXYPoint(object):
"""Implementation for PythonAddOn_addin.AddXYPoint_1 (Tool)"""
def __init__(self):
self.enabled = True
self.cursor = 3
def onMouseDownMap(self, x, y, button, shift):
fc = "Points"
workspace = r"C:\Temp\Test.mdb"
arcpy.env.overwriteOutput = True
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(workspace)
# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(True)
# Start an edit operation
edit.startOperation()
mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Points")[0]
message = "Your mouse clicked:" + str(x) + ", " + str(y)
pythonaddins.MessageBox(message, "My Coordinates")
point = arcpy.Point(x, y)
pointGeometry = arcpy.PointGeometry(point)
row_value = ((x, y))
cursor = arcpy.da.InsertCursor(fc, ("SiteNum", "SHAPE@XY"))
cursor.insertRow(row_value)
""" Create a copy of the PointGeometry objects, by using pointGeometry """
""" as input to the CopyFeatures tool. """
arcpy.CopyFeatures_management(pointGeometry, "C:\Temp\Test.mdb")
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)
arcpy.RefreshActiveView()
pass