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')
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.