so this is to check if any annotation overlaps and if it does it rotates one by 90 degrees
this just loops through the features and works fine
with arcpy.da.UpdateCursor(fc, ["objectid", "FeatureID","Angle" ,"SHAPE@", "SHAPE@X", "SHAPE@Y","LEGACY_TABLE_NAME"],"objectid in (4007789,4007788,4007787,4007786,4007791,4007790)") as Cur:
for row in Cur:
# read in the data
print row[0]
SA_Filter = "OBJECTID = {0}".format(row[0])
try:
arcpy.management.SelectLayerByAttribute(fc, "NEW_SELECTION", SA_Filter)
annocount = arcpy.management.GetCount(fc)
print "tmp count: {0}".format(annocount[0])
if int(annocount[0]) == 1:
print "selected one anno"
arcpy.management.SelectLayerByLocation(fc, "INTERSECT", fc, "", "NEW_SELECTION")
tmpcount = arcpy.management.GetCount(fc)
print "tmp count: {0}".format(tmpcount[0])
if int(tmpcount[0]) >= 2 and int(tmpcount[0]) < 74:
print "more than 1"
row[2] = float(row[2]) + 90
except:
print "Error"
but when i add in a simple update to a text field it fails
with arcpy.da.UpdateCursor(fc, ["objectid", "FeatureID","Angle" ,"SHAPE@", "SHAPE@X", "SHAPE@Y","LEGACY_TABLE_NAME"],"objectid in (4007789,4007788,4007787,4007786,4007791,4007790)") as Cur:
for row in Cur:
# read in the data
print row[0]
SA_Filter = "OBJECTID = {0}".format(row[0])
try:
arcpy.management.SelectLayerByAttribute(fc, "NEW_SELECTION", SA_Filter)
annocount = arcpy.management.GetCount(fc)
print "tmp count: {0}".format(annocount[0])
if int(annocount[0]) == 1:
print "selected one anno"
arcpy.management.SelectLayerByLocation(fc, "INTERSECT", fc, "", "NEW_SELECTION")
tmpcount = arcpy.management.GetCount(fc)
print "tmp count: {0}".format(tmpcount[0])
if int(tmpcount[0]) >= 2 and int(tmpcount[0]) < 74:
print "more than 1"
row[2] = float(row[2]) + 90
row[6] = "updated"
Cur.updateRow(row)
except:
print "Error"
