Select to view content in your preferred language

mxd.saveACopy - doesn't save appended Toolboxes

751
3
01-09-2011 10:50 AM
CosminTana
Emerging Contributor
Out of a toolbox, I run multiple scripts (in a certain row), one saves at the end the modified .mxd via

mxd.saveACopy("D:\\Filepath\\filename.mxd")

into a new "Copy" ( and opens it afterwards).

I have to open that new mxd for further modification (using the scripts in the same toolbox).
This must be done several times...so it's is quite annoying if I have to append the toolbox every time..

The problem is, this toolbox is NOT saved in that .mxd, so I have to append that toolbox again.
That means: mxd.saveACopy() does not save that toolbox in the copied project file (.mxd) - at least in my cases.


My Question is: what can I try that it might be included in the new"Copy"?
Is this maybe a bug?
I have ArcGIS 10 SP1 installed.

Any help is appreciated.Thanks.

some more information:

The the original .mxd was created before the toolbox was appended to ArcCatalog, anyway the Toolbox IS appended in that .mxd (probably by hand.. back then- before I appended it to ArcCatalog)

btw:
mxd.saveACopy() works fine from the python window, from appended scripts (using "Current" and absolute paths) the only problem i have is: my toolbox is not saved within the .mxd....
0 Kudos
3 Replies
JeffBarrette
Esri Regular Contributor
Hello Cosmin,

I'm not sure I completely understand the workflow, you please confirm or clarify the following: 
- You open an MXD (in the ArcMap application).
- Next you add some script tools to the Catalog Window (but you mention ArcCatalog, not Catalog Window) - I'm not sure what you mean by append.
- you do a saveACopy (to a different mxd)
- then you close the ArcMap application,
- reopen the same MXD and the toolbox is not available.  I.e., you must add it again.

Question: if you do the same thing with File-->SaveACopy, do you get the same behavior?

Thanks,
Jeff
0 Kudos
CosminTana
Emerging Contributor
Hi Jeff,
with "appended" I meant, the toolbox is added to the project (.mxd) as well as in ArcCatalog.
Since it is also added to ArcCatalog, I think this toolbox is included by default to every new project that will be created (=blank mxd).

If I save a Copy manually (via File->Save a Copy) everything is fine (my customized toolbox is included in the copy)

If I use mxd.saveACopy() from within the pythonwindow in ArcMap, my toolxbox is still there.

Untill Yesterday I had a script in the toolbox which referenced the mxd via ('Current').
In order to save time (not opening and closing that original mxd) I now run that script from ArcCatalog and it now references the original mxd via the filepath.

BUT the problem remains, the toolbox is not included in the Copy.

My Workflow at the moment is:
-Start a script from the toolbox in ArcCatalog.
  Basically this script just replaces some datasources according to the parameters.
  (workflow for one layer: 1. RemoveLayer 2.replaceDataSource 3. InserLayer
  since ReplaceDataSource makes them disappear if used alone)
   Anyway, it works fine now.
- at the end it saves the modified mxd via mxd.saveACopy()
- at the very last it starts that copy via os.starfile()
- next stept would be to run other scripts from that toolbox but I now have to re-add the toolbox first (the toolbox is definitely added to the original mxd)

Hope it is a bit clearer now.

I am wondering if this is a problem with my particular mxd or maybe the functions saveACopy() (called from a script) only saves the "system toolboxes".

Thanks for your help.
Cosmin
0 Kudos
CosminTana
Emerging Contributor
update:
a script which does just: saveACopy() works fine- on this mxd and on others.
So there is rather a problem with my script than with the settings or with the mxd...
0 Kudos