AnsweredAssumed Answered

arcpy.mapping.MapDocument (using "current" vs. file path)

Question asked by mkozub on Aug 12, 2015
Latest reply on Aug 13, 2015 by mkozub

Question for the Python folks.



I'm trying to add a feature class from my scratch .gdb and have been successful using arcpy.mapping.addLayer. I'm adding the feature class to the mxd which is set to the following:



mxd = arcpy.mapping.MapDocument("current")



The problem is I'm trying to publish a script tool to a web service, and I know I cannot use "CURRENT" so instead I use the file path of my MXD. While the script tool works, creates my feature class in the scratch .gdb, it does not automatically add the feature class to my TOC as the above line of code does.


Here's what I'm changing it to instead:


mxd = arcpy.mapping.MapDocument("C:\\users\\testUser\\desktop\\testMap.mxd")


The only difference in the entire script is where I'm changing the MXD path. Am I doing this wrong? Any suggestions or recommendations?