Make thumbnail using Python
Not sure if this is the right forum, but what code would I use in ArcGIS Desktop 10, using python to automatically make thumbnails of all of my MXD files.
Would this work:
mxd = arcpy.mapping.MapDocument(r"C:\Clients\2010\client1.mxd")
thumb = mxd.makeThmbnail(mxd)
I would be doing a recursive folder search to then list every MXD, so that I could make thumbnails.
Mapping Center Answer:
The syntax for creating thumbnails would be: mxd.makeThumbnail (), as you guessed.
ArcGIS 10 has a new embedded Python window where you can test your simple code.
We are not sure if you are asking how to do a recursive search and update thumbnails for all the MXDs at once or if you just want the syntax for creating a single thumbnail. If it is just one thumbnail, then the code above will work.
If it is the thumbnails for all the MXDs in a folder, I am providing you the code below that will loop through the provided folder (first level) and create the thumbnails for each MXD within that folder:
import arcpy, os
# Provide folder path to loop through (first level only)
folderPath = r"D:\MXD"
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
print "creating thumbnail for " + fullpath
You can modify this as needed.
Hope this helps!
If you would like to post a comment, please login.