rangermry

Add Layer Error

Discussion created by rangermry on Nov 9, 2012
Latest reply on Nov 14, 2012 by arekmatoszka
I am setting up a file to format a map template.  I am stuck at the Add Layer section.  I have a dictionary which is layer name:layer path.  I want to grab all the layer paths and add them as layers to the map template.  How can I fix my code?

TemplateLayers=(r"\\...\TemplateLayers.txt")
lyrDict={}
with open (TemplateLayers) as f:
    for line in f:
        (key,val)=line.split(",")
        lyrDict[(key)]=val
f.close()

print lyrDict

#Step 2: Pull the layers into the MXD at the bottom of the data frame from the dictionary.
for val in lyrDict.values():
    arcpy.mapping.AddLayer("",(val),"Bottom") 
I get: Runtime error <type 'exceptions.AssertionError'>:
When I print my dictionary it looks like this:
{'Roads':'\\\\filepath\\filename.lyr',etc....}

Outcomes