AnsweredAssumed Answered

Runtime error <type 'exceptions.IndexError'>: list index out of range

Question asked by arc_angel on Aug 16, 2012
Latest reply on Aug 22, 2012 by arc_angel
I am brand new to python coding, trying to figure out how to set up a script to allow me to apply the changes made to the .lyr's in one map to the .lyr's in other maps.

I've been working my way through the code samples found here:

Changing just the symbology works fine, but replacing a layer hasn't been.

here's the code, based on the ESRI example:
>>> mxd=arcpy.mapping.MapDocument(r"C:\Users\arc\Desktop\python_tutorial.mxd") >>> df=arcpy.mapping.ListDataFrames (mxd,"Layers")[0] >>> sourceLayer=arcpy.mapping.ListLayers(mxd,"orange",df)[0] >>> mxd2=arcpy.mapping.MapDocument(r"C:\Users\arc\Desktop\python_tutorial2.mxd") >>> df2=arcpy.mapping.ListDataFrames (mxd2,"Layers")[0] >>> updateLayer=arcpy.mapping.ListLayers(mxd2,"orange",df2)[0] Runtime error <type 'exceptions.IndexError'>: list index out of range

What exactly does that error message mean? I wondered if it had something to do with the names in my sources ("Layers", "orange") being the same as the names in my targets, but if I change the names I get the same error. I tried running it in Catalog, and still the same error. (I tried running it in commandline and through IDLE and found I had NO idea what I was doing.)

any help would be greatly appreciated.