Unsuccessfully trying to create a new label class using python. Forums have been helpful for figuring out python for the label class SQL query & expression, but now I want to add another class with a new query & expression.
Here's what I've got so far. I'm relatively new to python & have learned by trial & error & reading through these forums. What the below seems to do is rename the 'Default' label class. How do I add a new label class?
# Create Label Class for Single Layer Forested polys for lyr in arcpy.mapping.ListLayers (mxd): if lyr.name == MAPSHEET: if lyr.supports("LABELCLASSES"): for lblclass in lyr.labelClasses: lblclass.showClassLabels = True lblclass.className = "FLsingle" lblclass.SQLQuery = "\"CANLAY\" = 'S' AND \"US2CANLAY\" IS NULL" lblclass.expression = "\"{0}\" + [CANLAY] + \" - CC:\" + [CC] + \"{1}\"".format("<CLR red='0' blue='255' green='0'><FNT size = '11'>","</FNT></CLR>") # expression is currently incomplete lyr.showLabels = True arcpy.RefreshActiveView()
copy and paste it here then use the Advanced Editor in the top right of the post frame then look for the >> then select syntax highlighting and select python
Within a forest inventory I want to label certain types of forest polygons differently, as well as wetlands and other non-forest features. How do I post my python script!? (this is my first time posting a question here!)
what example are you working with?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.