Select to view content in your preferred language

Advanced Label Expressions with ArcPy

3699
7
10-20-2011 08:05 AM
Status: Already Offered
Labels (1)
johnhayes6
Deactivated User

Currently we are able to set a label expression with ArcPy by using the lblclass.expression method.  However, there is no way to check the "Advanced" box from ArcPy. 

0EM30000000CsoQ

There also doesn't appear to be a way to select with language parser is uesd (VBScript or JScript)

0EM30000000CsoV



It would be very helpful to have this capability.  In addition to this, being able to load precreated label expressions from ".lxp" files through ArcPy would be great. 

I would be extremely helpful if all of the settings in the label manager were exposed in ArcPy which include Label position, Fitting Strategy, and Conflict Resolution parameters.  All of this would fully enable complete automation over setting up labels for features.

Finally, it would be nice if the label engine (default or Maplex) could be set within a python script.

Thanks for considering!

7 Comments
FrankVignati
this would be extremely helpful for us using arcpy
ChrisMathers
Perhaps moving to python for labels as well instead of VB as there is a general move away from VB in arcmap.
ChrisFox
At 10.1 we added a new label expression parser for Python, so you can now build label expressions using Python.
RobertMartin2
Seems like the Python parser is a little buggy. For example, you can't escape double quotes with a backslash as you can in standard Python. When I do this none of my labels will draw.
curtvprice
A workaround is to use "\x22"
WilliamGreenwood1
The new label expression is not the same as the advanced checkbox.  the label expression can't contain return values and use conditional statements.
JeffBarrette
Status changed to: Already Offered

This should have been closed, at least for those that are using ArcGIS Pro.

The arcpy.mp API offers a number of ways of creating and managing labelClasses.

LabelClass—ArcGIS Pro | Documentation

Properties not directly exposed can be modified via Python CIM Access.

Jeff - arcpy.mp team