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.

I have developed a script tool for adding a layer in the current map document. It did not work.. The message is "Completed script addlayer...". But there were no layers added in the TOC. Another issue is when i type the same script in the python console window within Arcmap, the layer gets added. After adding the layer through console window, when i execute the script tool, it works and the layer gets added. I don't know what is the problem... pls help.. this is my script..

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
addLayer = arcpy.mapping.Layer(r"D:\Academic\M.E_thesis\data\ascii files\maxent\soil.lyr")
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
share|improve this question
Could you post the script as well as how you set up the script tool parameters? –  blah238 Apr 17 '13 at 6:39
Edit your question to add code or clarify information. Do not use the comments area unless responding with a short "comment". –  blah238 Apr 18 '13 at 5:46
That was my script.. I did't set any parameters. Since i defined my workspace and the layer file in the script, i did't use any parameters.. –  Aishwarya R Apr 18 '13 at 5:47
I have ArcGIS10.. When I run the same script in ArcGIS10.1, I don encounter any of the above problems –  Aishwarya R Apr 18 '13 at 6:27
mxd.save() may be all you need? –  Ron Beloin Apr 18 '13 at 17:00

Your Answer


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

Browse other questions tagged or ask your own question.