Select to view content in your preferred language

Create a new MXD through Python.

5030
0
07-15-2014 03:06 PM
AlexanderNohe1
Honored Contributor
5 0 5,030

I have found this helpful by looking through some documentation on stack exchange a while back.  Thought that I might share this here as well.

This is a script that can be used to create a new MXD for ArcMap in python.  This will allow you to create a new MXD and then modify it using the ArcPy mapping module.  This functionality is not currently present in ArcPy so this script uses comtypes to call ArcObjects to create it.  Depending on what version of ArcMap that you are running, you may need to change line 9 or 10 in the Snippets.py file to point to the correct assembly reference.  (You will want to run run.py)

Modify line 8 in run.py to specify the location of the MXD to be created.

Sources used:

Accessing ArcObjects from Python?

http://gis.stackexchange.com/questions/80/accessing-arcobjects-from-python

Using ArcObjects in Python

http://www.pierssen.com/arcgis/upload/misc/python_arcobjects.pdf

I hope some users will find this useful.

Tags (3)
About the Author
github.com/nohe427
Labels