[GIS] Why does ArcGIS “forget” the specified default GDB for a map document (mxd)

arcgis-10.0arcgis-desktopfile-geodatabase

I'm using ArcGIS 10.0 on Windows 7 64 bit Ultimate.

I've noticed that sometimes ArcMap's geoprocessing tools as well as scripts seem to forget my setting in the mxd (confirmed via arcpy.env.workspace and arcpy.env.scratchWorkspace.

Is there any way to get ArcMap to start using my specified GDB?

I'm familiar with the document properties and how I can change the default GDB for a map. The issue I'm seeing happens after I've set it and its been using an alternate GDB for a while.

I find that at random times, ArcGIS suddenly decides it wants to go back to using the "default default" (which annoyingly can never be changed. I can close and reopen the document, set the alternate GDB I use as the default againvia the properties dialog, but it will not move back to using the alternative GDB. Toolbox and scripts keep placing output in the default ArcGIS location (documents/ArcGIS/default.gdb).

I was however playing around with this and found manually settings the arc.env.workspace in the Python window seemed to magically bring it back (even though I was setting the same value?). Executing the verbatim sa tool I had just ran put output into the correct GDB even though the dialog settings nor the environment settings had "changed".

Has anyone else come across this behavior?

Best Answer

This ArcGIS help for Setting the Default Geodatabase might be what you are looking for. I believe the "Default" is something that has to be set upon each map document's creation. After that, it should be accessible through the settings in the MXD. I'm away from my station so I can't confirm the exact toolbar rigamarole.

However it should be noted that your scratch Workspace is not always the same as your Workspace (they are different by default, if I recall). When using arcpy, environments are inherited if you use the arcpy.mapping class to create a reference to a given MXD (I think), but I know they can all be set through use of arcpy.env.

If you want to set your database/workspace specifically when using a Geoprocessing tool in ArcMap, you can :

  1. In ArcMap, click Geoprocessing > Environments. This opens the Environment Settings window.
  2. Expand the Workspace category and enter the path to the workspace.
    (See This page for more information.)