Select to view content in your preferred language

Possible to run python scripts on unopened mxds?

939
4
08-31-2012 10:38 AM
AllenSmith
Deactivated User
Is it possible to run a pyhton script on an unopened mxd?  I was thinking of a havinga "Master" map that users could digitize polygons in and then run a tool that applied their new polygon (as a definition query) to three other mxds.  I have scripts that run individually (1 per map) and was hoping to combine them into a single tool.  Am I way off base?  Is it simply a matter of referencing the three mxds?  Thanks.
Tags (2)
0 Kudos
4 Replies
KevinYanuk
Deactivated User
Is it possible to run a pyhton script on an unopened mxd?  I was thinking of a havinga "Master" map that users could digitize polygons in and then run a tool that applied their new polygon (as a definition query) to three other mxds.  I have scripts that run individually (1 per map) and was hoping to combine them into a single tool.  Am I way off base?  Is it simply a matter of referencing the three mxds?  Thanks.


I'm not sure if you can edit features in the map itself.

You can reference a map doc and print it's contents at the very least:

import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\Users\user\path\to\mxd.mxd')


for lyr in arcpy.mapping.ListLayers(mxd):
    print lyr.name


What do you mean by
a tool that applied their new polygon (as a definition query) to three other mxds.
0 Kudos
AllenSmith
Deactivated User
What I was hoping to do was apply a definition query across 3 different mxds with 1 script and without opening each mxd individually.
The definition query would run a selection by location in one map, a clip process in another and a second select by location function in
a third.  It is not possible to have a single mxd with all of this in it.  Thanks for you help.
0 Kudos
ChristopherThompson
Frequent Contributor
The definition query would run a selection by location in one map , a clip process in another and a second select by location function in a third.


Definition queries don't do these things, rather they limit what is visible in a layer based on SQL 'where' clause.  Rather you want 3 different geoprocessing tools that create different output datasets.  Layers in your 3 different maps could then be 'pointed' at each of the datasets that are appropriate.  Could you lay out your problem a little more clearly?  I think this is certainly doable using arcpy.
0 Kudos
AllenSmith
Deactivated User
Chris,

I have 3 mxds (Tract, Soils, Location).  All 3 use the same geodatabase feature class in which the user specifies a certain tract (definition query).  I have 3 separate python scripts (1 for each map).  The first map uses the definition query to zoom and display the tractt and interior polygons over aerial imagery.  The second uses the definiton query to clip a soils layer and display tabular data.  the third mxd uses the same definition query to show the general tract location as well as some intersecting data.  Currently, I have to open each map independently and run it's resepctive script.  I would like to run all 3 mxds at once, with a single button push.  T should note that the selected polygon (defintion query) needs to be temporary.  Thanks.
0 Kudos