Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever I attempt to use AddLayer it gives me: Runtime error <type 'exceptions.AssertionError'>

This is what I've been using:

arcpy.mapping.AddLayer(MainDF, r"\\GEOGDATA\campusmapping\CampusWide\LayerFiles\CAD\Floor2\Casanova2", "BOTTOM")

Casanova2 is a .lyr file. I've also attempted to use this with a few other layer files. Every time it gives me an AssertionError.

Do you know what I'm doing wrong?

share|improve this question
Have you tried a local path instead of a network path? – MathiasWestin Sep 19 '10 at 13:20
up vote 9 down vote accepted

I figured out the problem. The second parameter needs to be a previously-defined layer, not a string that points to the layer.

addLayer = arcpy.mapping.Layer(r"\\GEOGDATA\campusmapping\CampusWide\LayerFiles\CAD\Floor2\Casanova2")
arcpy.mapping.AddLayer(MainDF, addLayer, "BOTTOM")

Works great.

share|improve this answer

Hard to say, have you followed the sample here? API documentation: AddLayer

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.