2

I am using ArcMap 10.2. I used the following code to turn all the layers on for the Main Map data Frame.

dFrame = arcpy.mapping.ListDataFrames(current_mxd,"Main Map")[0]
    for lyr in arcpy.mapping.ListLayers(current_mxd, "", dFrame):
        lyr.visible = True

Does anyone know how to use ArcPy to turn every layer on for all the data frames?

2
  • 1
    for dFrame in arcpy.mapping.ListDataFrames(current_mxd) will cycle through the data frames.. the wildcard is optional. Jul 31, 2018 at 0:50
  • 2
    All you need is a for before dFrame, an in where the equals is, empty quotes in the ListDataFrames, and to remove the array index.
    – Vince
    Jul 31, 2018 at 0:50

1 Answer 1

2

You use the same coding pattern for looping through your data frames as you do for looping through your layers.

for dFrame in arcpy.mapping.ListDataFrames(current_mxd):
    for lyr in arcpy.mapping.ListLayers(current_mxd, "", dFrame):
        lyr.visible = True

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.