Launch Python script on mxd open?

2979
2
Jump to solution
01-25-2013 11:06 AM
by Anonymous User
Not applicable
We are upgrading/migrating to a new SDE server, leaving my organization with probably thousands of .mxds with datasource references pointing to the old, soon to go away, server.

I could write a py script to rifle through all of these .mxd's and do a datasource replace, but I'm envisioning some problems that could occur.  The end-users are typically casual GIS users, so attempting to instruct all of them how to fix broken data links is probably a non-starter.

My preference would be, on opening an .mxd, to automatically run a script that checks for data sources referencing the old server and offers to replace them for the user, then lets them decide whether to replace the old .mxd or write out a new one.

Is there any way to get ArcMap to run a specific Python script when opening an existing .mxd?  I can access the user's local directories to push/replace files as needed.

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MelanieMaguire
New Contributor III
If you are using ArcGIS 10.1, you can create a Python add-in (application extension) with code that executes on the open document event.  Here is a page from ESRI's help listing the events that you can respond to with Python.  The help page for application extensions has a python example of code that executes on the open document event.

View solution in original post

0 Kudos
2 Replies
MelanieMaguire
New Contributor III
If you are using ArcGIS 10.1, you can create a Python add-in (application extension) with code that executes on the open document event.  Here is a page from ESRI's help listing the events that you can respond to with Python.  The help page for application extensions has a python example of code that executes on the open document event.
0 Kudos
by Anonymous User
Not applicable
I should have mentioned, we are at Desktop 10.0.   Unfortunately, I have to upgrade the database (9.2) to 10.0 before I can upgrade my Desktops to 10.1.     I'd much prefer to get the database out of the way before tackling the Desktop upgrades, but I'll definitely investigate the Python add-on at 10.1, which would at least minimize the gap where I can't automate some of the broken datasource issues.  Thanks.
0 Kudos