I am quite a beginner with programming in python and I am struggling with my code. I would like to create new points(trees) on my map using mouse click and afterwards add them to the existing attribute table. I managed to locate points with mouse click however they are not added to the table, it is always one row (even I added 10 points) and the columns(ID, tree, Lat and Long) are not there as well (only ID, Shape..). I tried to connect it directly to the existing data set but then when I locate a new tree all other trees are disappearing and attribute table is containing one row as well.
def onMouseDownMap(self, x, y, button, shift): #adding points to the map mxd = arcpy.mapping.MapDocument ("CURRENT") sr = mxd.activeDataFrame.spatialReference pntFc = r"\\abc\home\xxx\Documents\moje dokumenty\xyz\arcgis\treepoints" #new polygon ofc=r"\\abc\home\xxx\Documents\moje dokumenty\xyz\arcgis\trees" #existing data set fields=["OID@","Tree","Lat", "Long"] Lat="SHAPE@X" Long="SHAPE@Y" pt = arcpy.Point() pt.X = float(x) pt.Y = float(y) ptGeoms = [arcpy.Geometry ("POINT", pt, sr)] if not arcpy.Exists (pntFc): arcpy.CopyFeatures_management(ptGeoms, pntFc) else: with arcpy.da.InsertCursor (pntFc, fields) as iCurs: #create insert cursor #insert row for pt in ptGeoms: row=iCurs.insertRow() arcpy.RefreshActiveView() print "Complete"