Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

2 Answers 2

up vote 6 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

 
discard

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.