I am trying to convert the label for a point layer to annotation. Below is my script and the error I am getting.
import arcpy
from arcpy import env
import arcpy.mapping
# Set environment settings
env.workspace = "C:\Users\Documents"
arcpy.env.overwriteOutput = True
#define projection
Prjfile = r"C:\\Users\\Documents\\WGS1984.prj"
spRef = arcpy.SpatialReference(Prjfile)
#Local Variables
FC7 = r"C:\Users\Documents\South.gdb\Search_Ring"
mxd = arcpy.mapping.MapDocument(r"C:\Users\Documents\Demo_South.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
## Convert Feature class to feature layer
arcpy.MakeFeatureLayer_management(FC7, r"C:\Users\Documents\Search_Ring.lyr")
layer7 = arcpy.mapping.Layer(r"C:\Users\Documents\Search_Ring.lyr")
Sym_layer7 = r"C:\Users\Documents\Search Ring.lyr"
## Apply symbology and add layer to MXD
arcpy.ApplySymbologyFromLayer_management (layer7, Sym_layer7)
arcpy.mapping.AddLayer(df, layer7, "TOP")
lyr7 = arcpy.mapping.ListLayers(mxd, "", df)[0]
## Add the labels and its format
lyr7.labelClasses[0].expression = '"{}" + [Candidate_Code] + "{}"'.format("<CLR blue='255'><FNT size = '9'><BOL>", "</BOL></FNT></CLR>")
lyr7.showLabels = True
## Convert label to Annotation
arcpy.ConvertLabelsToAnnotation_defense (mxd, "")
## Add Layer Properties
lyr7.visible = False
lyr7.name = "Search_Ring"
lyr7.maxScale = 0;
lyr7.minScale = 5000000;
lyr7.transparency = 25;
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
## Save the mxd
mxd.saveACopy(r"C:\Users\Documents\South.mxd")
del mxd,df
ERROR:
Any help is appreciated.
Thanks
have you enabled the extension?
Seems like I don't have this defense mapping extension. Is there any other way to do it.
close Converting labels to annotation features—Help | ArcGIS for Desktop
or manually using this Converting labels to annotation—Help | ArcGIS for Desktop
I don't use them but the only other references are to lessons or the military analyst
Another tool to explore is Tiled Labels To Annotation.