Perhaps I should move this to a new post? Oh well, it's essentially the same question originally posted and unanswered.I'm struggling through a crash course in Arcpy this week. I've been putting this off for years. 🙂I want to turn on (make visible) a Group Layer for each index page of my DDP. In my TOC:"GroupLayer1" to "GroupLayer30". 30 Group Layers named same as my DDP index field.A "New Basemap Layer"I've believe the answer may along one or more of these concepts:lyr.longName equal to lyr.name then lyr.visible = true, else false?http://forums.arcgis.com/threads/957-Beta-10-List-Comprehensions?highlight=map+group+layer+u%27yet another snippet I'm experimenting with, but currently only returns the "else" argument...import arcpy, os
... mxd = arcpy.mapping.MapDocument(r'C:\GIS\PROJECT\FrustratingArcPy.mxd')
... idxLyr = arcpy.mapping.ListLayers(mxd, 'MapBook_OCT09')[0] # The DDP index FC
... Group = arcpy.mapping.ListLayers (mxd)
... df = arcpy.mapping.ListDataFrames(mxd, 'MapBook')[0] # The Data Frame name
... pageNameField = "Page_Title" #DDP Index Field
...
... rows = arcpy.UpdateCursor(idxLyr)
...
... for row in rows:
... pageName = row.getValue(pageNameField).encode('ascii')
... pageID = mxd.dataDrivenPages.getPageIDFromName(pageName)
... mxd.dataDrivenPages.currentPageID = pageID
... if str(pageName) == str(Group):
... print str(Group) + str(" ") + str(pageName)
... else:
... print str(Group)
... del mxd, row, rows
Another incomplete sample which returns all Group Layers, including the "New Basemap Layer": import arcpy, os
... from arcpy.mapping import * #Brings in entire functionality of the mapping module
... mxd = arcpy.mapping.MapDocument(r'C:\GIS\PROJECT\FrustratingArcPy.mxd')
... layerlist = arcpy.mapping.ListLayers(mxd)
... for lyr in layerlist:
... if lyr.isGroupLayer:
... lyr.visible = True
... print str(lyr)
... else:
... lyr.visible = False
... arcpy.RefreshTOC()
... del mxd
Please help?!Thanks!Kerry