I am trying to select a polygon then it must automatically change (calculate) the status to "C". The tool seems to work in the background but nothing actually happens (the status is not updated). I have used the code from this post but nothing actually gets selected. If I have a feature in the layer selected already it does deselect it though.
Below is the code that i am using. Is there something that I have gotten wrong? Thanks for any help.
import arcpy import pythonaddins def getSearchDistanceInches(scale, selection_tolerance=3): """Returns the map distance in inches that corresponds to the input selection tolerance in pixels (default 3) at the specified map scale.""" return scale * selection_tolerance / 96.0 # DPI used by ArcMap when reporting scale class tlStatToC(object): """Implementation for PythonAddin_addin.tlMapCoods (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. 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) # assumes you want to select features from 1st layer in TOC arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", pointGeom) arcpy.RefreshActiveView() arcpy.CalculateField_management(lyr,"STATUS","C")