Neftex

renaming a layer thats just been created

Discussion created by Neftex on Dec 20, 2011
Latest reply on Jan 3, 2012 by jbarrette-esristaff
Hi,

I am creating a layer with python, is there a way of renaming it immediately or a way to identify what layer was just added so I can rename it, see code below:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, "", df)
words = ['curpm1', 'curpm2', 'curpm3']
for word in words:
    print word
    groupLayer = arcpy.mapping.Layer(r"C:\Users\oliverm\Desktop\GIS1\GL1.lyr")
    arcpy.mapping.AddLayer(df, groupLayer, "BOTTOM")
    'rename layer here'

Thank you very much for your help, I ideally want to be able to create the newly added layer as one of the list words.

Oliver

Outcomes