The following script joins two layers on a common id and attempts to use the OBJECTID in the joined table to update records for a field in the input table. In running it in "current" mode, it moves through the join process ok but then errors out with Calculate. OBJECTID is from a joined table and I am joining it to an Annotation class, but I'm not sure that is relevant. Any ideas as to why this doesn't complete?
mxd = arcpy.mapping.MapDocument("Current") dflist = arcpy.mapping.ListDataFrames(mxd) for df in dflist: if df.name == "County": for lyr in (arcpy.mapping.ListLayers(mxd, "", df)): if lyr.name == "County Insets": CoInset = lyr elif lyr.name == "County Insets Anno": CoAnno = lyr print 'Joining ' + CoInset.name + ' to ' + CoAnno.name arcpy.AddJoin_management(CoAnno, "TempID", CoInset, "TempID") expression = "!" + CoInset.name +".OBJECTID!" arcpy.CalculateField_management(CoAnno, "FeatureID", expression, "PYTHON")
This gives me the following error:
Runtime error Traceback (most recent call last): File "<string>", line 14, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 3129, in CalculateField raise e <br> ExecuteError: ERROR 000539: Invalid field County Insets.OBJECTID Failed to execute (CalculateField).