1

Originally I was trying to add a empty layer that was stored on disk. That contained no data. I created the empty layer , by making a group layer within my mxd and then saving it onto a location on my computer

The process was detailed here

Create empty group layer within group layer

My original question was "once my layer has been added to my group layer . How do I rename it "

At the time I was struggling to understand how to access empty layer I had just added. I was getting bogged down in trying to understand the list feature of the group and its sub groups. Thinking I need to access the Empty layer first by going into its top level group. But In this case I did not need to list the layers because I was all ready able to access the layer from the code that had loaded into my Group

So all that is needed to add to the code , as supplied on the previous post is

mxd = arcpy.mapping.MapDocument(r"C:\Temp\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
groupLayer = arcpy.mapping.Layer(r"C:\Temp\Group.lyr")

Inside here you can then rename the layer you another name

groupLayer.name = 'NEW_NAME'

arcpy.mapping.AddLayer(df, groupLayer, "BOTTOM")
targetGroupLayer = arcpy.mapping.ListLayers(mxd, "Group", df)[0]
addLayer = arcpy.mapping.Layer(r"C:\Temp\Group2.lyr")
arcpy.mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")
mxd.save()
del mxd,df
0

Browse other questions tagged or ask your own question.