Thank you for any help/guidance that you can provide, I'm really hoping someone can help me with this problem. The script is supposed to go through a selection of objects and export each one into a separate file in the prompted location, it should isolate each object, frame it and generate a maya thumbnail for use with the content browser. Below is the code:
import maya.cmds as cmds
import os
# Get a list of selected objects
selected_objects = cmds.ls(selection=True)
if len(selected_objects) == 0:
cmds.warning("Please select and object to export")
else:
# Prompt the user for the location to export the files
export_location = cmds.fileDialog2(fm=3, dir=os.path.expanduser('~'))[0]
# Iterate over the selected objects
for object in selected_objects:
# Select object
cmds.select(object)
# Isolate the current object
cmds.isolateSelect('modelPanel1', loadSelected=True)
# Take a thumbnail of the current object
cmds.viewFit(object)
# Create thumbnail capture
cmds.thumbnailCaptureComponent(capture=True, save=export_location + "/" + object + ".ma")
# Use the file command to export the object
cmds.file( export_location + "/" + object + ".ma", type='mayaAscii', exportSelected=True, force=True )
# Reset the isolation
cmds.isolateSelect('modelPanel1', state=False)
It does most of what I require it to do other than isolating the object correctly and exporting a thumbnail for each object. I would prefer if the cmds.thumbnailCaptureComponent didn't prompt and just generated the thumbnail automatically, but if it has to prompt that's fine too. Currently it only seems to generate a thumbnail for the last selected object rather than the object it is currently on in the for loop.