I have a program (720 lines of code) that runs multiple tasks on Arcmap .mxd files. Such as update layers, update text, add layers, etc.
Within my program I have multiple "mxd.save()" instances. All of which occur within for loops.
For example:
for item in mxds:
mxd = arcpy.mapping.MapDocument(item)
df=arcpy.mapping.ListDataFrames(mxd,"Project Area")[0]
print "HOWDY!"
mxd.save()
Question is can I just have at the very end of my program have one for loop that saves all the mxds I was working on, while still retaining all the changes?
UPDATE:
Problem I think am having is this. I have one of my for loops that adds a layer to the map. If I do not mxd.save() after that layer is added. My program later when it attempts to find the layer that was added cannot find it. I guess it's not held in memory.
UPDATE2:
THANKS! I was doing something similar, but wrong none the less. Each time I had a for loop I would create a new .MapDocument object which I realized (thanks to you) was unnecessary. I now define the mapdocument object once at the start of my program and work from there. Do this has also greatly increased the speed of my program.