I want to use ArcPy to turn on the labels for a layer.
I use this code but it fails and returns an error.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Users\P51\Desktop\testingLABEL.mxd") df = arcpy.mapping.ListDataFrames(mxd,"Layers") layer = arcpy.mapping.ListLayers(mxd, "point10", "Layers") layer.showLabels = True
This is the error :
Runtime error Traceback (most recent call last): File "<string>", line 4, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\mapping.py", line 1517, in ListLayers result = mixins.MapDocumentMixin(map_document_or_layer).listLayers(wildcard, data_frame) File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\arcobjects\mixins.py", line 843, in listLayers raise TypeError(str(type(dataframe))) TypeError: <type 'str'>
Does anyone know how to fix this?
I have many layers (100 layers/feature class/ file geodatabase) and I want to label those layers then I convert those layers into annotation and after that I convert them to DWG CAD (point and annotation), but I want to do that automatically (especially when do labeling and turn on those label), because it will be wasting time if labeling those 100 layers 1 by 1.