I’ve been working on updating our animation library tool at work for use in Maya 2012 and noticed an issue with properly generating thumbnails. After scouring the internet for awhile, I found out I wasn’t the only one experiencing an issue with the playblast command. When using the completeFilename flag (to save an image without zero-padding), the image won’t save, and Maya raises no warnings or errors about it.
Fortunately, I came across a post from Nathan Horne, showing how to generate thumbnails using the Maya API commands. I added some additional checks to the original snippet:
def writeThumbnailFromView(filename, compression, modelPanel=None): #Import api modules import maya.OpenMaya as api import maya.OpenMayaUI as apiUI #Grab the last active 3d viewport view = None if modelPanel is None: view = apiUI.M3dView.active3dView() else: view = apiUI.M3dView() apiUI.M3dView.getM3dViewFromModelEditor(modelPanel, view) #read the color buffer from the view, and save the MImage to disk image = api.MImage() view.readColorBuffer(image, True) image.writeToFile(filename, compression)
So far it seems more efficient for my needs than the playblast command, as my tool is now able to avoid capturing the wrong viewport, and I can control the image without messing with render settings.