Problems creating an MXD thumbnail.

3219
1
05-30-2013 09:45 AM
PrestonMcCormick
New Contributor II
I would like to create a thumbnail for a map document, but I've run into problems.  I've found two avenues of aproach, but neither works well.

Method 1 opens the MXD with the MapDocumentClass and then saves using IMapDocument.Save(useRelativePaths, createThumbnail).  This method works for simple map documents.  But, any map layers with a transparency setting will not show in the thumbnail.  Their labels will show, but not the features.  For the maps I'm working with, this results in an unrecognizable thumbnail.

Method 2 uses IDocumentPreview.CreatePreview method off of an MxDocumentClass retrieved from the currently open map document in ArcMap.  This method used to work in ArcMap 9 (as long as the document already had a thumbnail).  It does not seem to work in ArcMap 10.  I have tried setting the IDocumentInfo.SavePreview flag to true and flagging the document as dirty before save, but nothing results in a thumbnail saved with the MXD.

I think it should be possible to get this to work, since the CreateThumbnail button in the Map Document Properties dialog works.  Does anyone have some working code?
0 Kudos
1 Reply
by Anonymous User
Not applicable

I don't have any working cod, but I ran the following script and had problems.  Every map document in the folder reverted back to 8 1/2 x 11 inch page sizes targeted to my default printer.  I lost all my large-format printer settings and had to reposition and resize every element in the layout view, causing me to redo hours of work done over the last few days.  Yes, I should have tried with only one map document as a test, but it's a hard less to relearn.

import os
import os.path
import arcpy.mapping
mapFolder = os.curdir
for mapDoc in os.listdir(mapFolder):   
    if os.path.splitext(mapDoc)[1] == '.mxd':
        mapPath = os.path.join(mapFolder, mapDoc)
        print 'Regenerating thumbnail for ' + mapPath + '...'
        mxd = arcpy.mapping.MapDocument(mapPath)
        mxd.deleteThumbnail()
        mxd.makeThumbnail()
        mxd.save()
        del mxd
0 Kudos