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')
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.