Collapse symbology in TOC

Discussion created by clm42 on Sep 10, 2012
Latest reply on Sep 13, 2012 by jbarrette-esristaff
We are about to do some major rearranging in our SDE (moving into the Local Gov Info Model) and I've written a script to re-source automatically those feature classes that are moving in any MXDs they appear in. I don't want the users to experience any changes to the way their MXDs look when they open them. I know I can catch whether a layer is visible or not and set that back but I don't see that I can set if the symbology is collapsed in the TOC. Just wanted to verify this. When I update to the new LYR if the TOC has that layer expanded it will save in the edited MXD as expanded and I dont want that if I can avoid it. Below is the code I wrote this morning to make the changes to the map documents.

import arcpy, os


for root, dirs, files in os.walk(top_directory_of_search):
    mxds=[x for x in files if x.endswith('.mxd')]
    if len(mxds)!=0:
        for mxd_path in [os.path.join(root,mxd) for mxd in mxds]:

for mxd_path in paths:
    for df in arcpy.mapping.ListDataFrames(mxd):
        for layer in arcpy.mapping.ListLayers(df):
            if layer.dataSource in Layer_Replacements:
                layer.replaceDataSource(Layer_Replacements[r'Database Connections\OSA@sde@bay-gis.sde','SDE_WORKSPACE',Layer_Replacements[layer.dataSource][0])