I'm trying to add a tool to an add-in toolbar to select features from an existing feature class and copy attributes to another feature class, from point to point.
TopoHeight_Field_Name='Comment'
def testing(mxd,Transfare_Anno_row):
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name=="sManhole":
msg= "Your Layer is " + str(lyr)
with arcpy.da.UpdateCursor(lyr,TopoHeight_Field_Name) as cursor:
pythonaddins.MessageBox(msg, "My Layer")
for row in cursor:
pythonaddins.MessageBox(msg, "My Layer")
row[0]=Transfare_Anno_row
cursor.updateRow(cursor)
class SelectByLine(object):
"""Implementation for SelectByLine_addin.tool (Tool)"""
def __init__(self):
self.enabled = True
self.shape = 3
def onMouseDownMap(self, x, y, button, shift):
mxd = arcpy.mapping.MapDocument("CURRENT")
pointGeom = arcpy.PointGeometry(arcpy.Point(x, y), mxd.activeDataFrame.spatialReference)
searchdistance = getSearchDistanceInches(mxd.activeDataFrame.scale)
lyr = arcpy.mapping.ListLayers(mxd)[0] # assumes you want to select features from 1st layer in TOC
arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", pointGeom, "%d INCHES" % searchdistance)
with arcpy.da.SearchCursor(lyr,TextString_Field_Name) as cursor:
for Anoorow in cursor:
Anno_row=Anoorow[0]
SourceFlag=1
message = "Your mouse clicked:" + str(x) + ", " + str(y)+"Your Layer is" + str(lyr)+"Your Anno Filed is" + str(Anno_row)
pythonaddins.MessageBox(message, "My Coordinates")
if SourceFlag:
testing(mxd,Anno_row)
When I Call the testing function it will send the first message box but can not send the second message box and is not updating the row.