how can we set Label scale and placement property using arcpy?

09-27-2016 02:01 PM
New Contributor III

Below is the code and what I am trying to do is set the scale range on Label minScale = 500000; and label placement should be top center only. I am sure how to automate this through arcpy. 

arcpy.MakeFeatureLayer_management(FC7, r"C:\Users\Documents\Search_Ring.lyr")
layer7 = arcpy.mapping.Layer(r"C:\Users\DocumentsSearch_Ring.lyr")
Sym_layer7 = r"C:\Users\Documents\Symbology layer new\Search Ring.lyr"
arcpy.ApplySymbologyFromLayer_management (layer7, Sym_layer7)
arcpy.mapping.AddLayer(df, layer7, "AUTO_ARRANGE")
lyr7 = arcpy.mapping.ListLayers(mxd, "", df)[0]
lyr7.labelClasses[0].expression = '"{}" + [Candidate_Code] + "{}"'.format("<CLR blue='255'><FNT size = '9'><BOL>", "</BOL></FNT></CLR>")
lyr7.showLabels = True
lyr7.visible = False = "Search_Ring"
lyr7.maxScale = 0;
lyr7.minScale = 25000000;
lyr7.transparency = 25;

Tags (2)
4 Replies
MVP Legendary Contributor

your hightlighted line doesn't look right since it isn't python-esque.  Did it throw an error? and I assume you have gone through the link LabelClass—Help | ArcGIS for Desktop 

0 Kudos
New Contributor III

No it doesn't throw an error. It does show labels with the format I mentioned in that line. Now I want add the scale to the label and set the placement property to it. Which I have no idea how to do it.

0 Kudos
MVP Esteemed Contributor

I don't believe you can.  ArcPy doesn't implement the entire ArcGIS for Desktop object model or API, it implements a subset.  The ArcMap LabelClass is fairly limited.  In your case, it doesn't offer access to scale or placement properties.

New Contributor III


0 Kudos