It prints the classes' names, and then it blows up with the error below.
Can somebody clue me in, please?
TIA
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.activeMap
for lyr in m.listLayers("*"):
lblClass = lyr.listLabelClasses()[0]
print(lblClass.name)
lblClass.expression = "$feature.Text"
lyr.showLabels = True
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 529, in listLabelClasses
return convertArcObjectToPythonObject(self._arc_object.listLabelClasses(*gp_fixargs((wildcard,), True)))
RuntimeError
Solved! Go to Solution.
Never mind. It worked, but it threw the error because I had CAD layers in the TOC.
Never mind. It worked, but it threw the error because I had CAD layers in the TOC.