I’m having an issue scripting out exporting selected objects from Maya.
The first problem is, that it won’t export selected objects until I manually export selected first before running the script (If I don’t run this manually first it will export out the whole scene not just the selected).
Second issue is if I export out a lot of objects from one scene, I run into the memory issue that Maya is so well known for and it ends up crashing.
Do you know of any exporting selection thru the API? I’ve tried MEL, Python and Pymel but they all cause the same issues (because they are all wrappers around the MEL function).
#Here is some sample code I have if it helps
import pymel as pm
def exportTARGShapes(path, blendNode=“blendShape1”):
if not path:
path = pm.fileDialog(m=0, dm="*.ma")
if path:
numTargets=len(pm.getAttr(blendNode+".w"))
for iterator in range(numTargets):
originalName=pm.aliasAttr("%s.w[%i]"%(blendNode,iterator), q=True)
try:
pm.setAttr(blendNode+"."+originalName, 1)
dup = pm.duplicate("geoToExportGroup")
dup = pm.rename(dup, originalName)
pm.parent(dup, w=True)
pm.select(dup)
pm.exportSelected("C:/Documents and Settings/user/Desktop/exportFolder/%s.ma"%originalName,
constructionHistory=False,
constraints=False,
expressions=False,
shader=False)
pm.delete(dup)
pm.refresh()
pm.setAttr(blendNode+"."+originalName, 0)
except:
pass
Thanks for any help.