Create a Map document (Mxd or Msd) through python script

2017
2
03-10-2011 02:26 AM
nidhiarora
New Contributor
Hi,
I have a folder which contains n number of shapefiles. With every update, the count of shapefile varies.
Is it feasible, through Geoprocessing script to create a map document by automatically picking all the shape files from the folder? 
Regards,
Nidhi
Tags (2)
0 Kudos
2 Replies
JasonScheirer
Occasional Contributor III
You will need a map file somewhere on disk, but you can save copies of it. What you would do is open an MXD with arcpy.mapping.MapDocument, then a layer file with arcpy.mapping.Layer, use layer.replaceDataSource to make it point to the shapefile, then use arcpy.mapping.AddLayer to add the layer which now points to the shapefile to the map document. You would continue until you've added all your layers and then call saveACopy on the MapDocument object to produce your new MXD with all your data sources.
0 Kudos
nidhiarora
New Contributor
Thnx got it working

regards
Nidhi
0 Kudos