earaujoimg-com-br-esridist

Read MXD path

Discussion created by earaujoimg-com-br-esridist Employee on Apr 12, 2013
Latest reply on Apr 12, 2013 by jmoulds-esristaff
Hy Guys,

I'm new in python and I would like to know if there is a way to read the MXD path (e.g C:\temp\arquivo.mxd) ?

I have to create a MXD, then open it and add some layers, I tried this:
import arcpy, os

mxd = file("template1.mxd", "a")
mxd.close()
mxd1 = arcpy.mapping.MapDocument(mxd)
df = arcpy.mapping.ListDataFrames(mxd1, "Dados")[0]
addLayer = arcpy.mapping.Layer(r"D:\Eduardo\Dados_teste\Temp\sanepar\TemplateFlags.lyr")
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
mxd1.save()
del mxd1, addLayer

It works if the MXD is previously created but I'd like to create a blank MXD.  I don't know how to pass the mxd full path to arcpy.mapping.MapDocument.

Thanks,
Eduardo

Outcomes