import arcpy import pythonaddins from arcpy import mapping as m class AddFeatureWithXY(object): # Implement the add in def __init__(self): self.enabled = True self.cursor = 3 # cross def onMouseDownMap(self, x, y, button, shift): # listens for mouse down event mxd = m.MapDocument("current") df = m.ListDataFrames(mxd)[0] lyr = m.ListLayers(mxd, 'Addresses', df)[0] # Get XY from click pt=arcpy.PointGeometry(arcpy.Point(x,y)) insert = tuple([pt, x, y]) # insert rows coord_fields = ['SHAPE@','POINT_X','POINT_Y'] with arcpy.da.InsertCursor(lyr, coord_fields) as irows: irows.insertRow(insert) arcpy.RefreshActiveView() pythonaddins.MessageBox('Added X,Y coords to table', 'Message', '0')
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.