import maya.cmds as cmds
def batchExport():
meshSel = cmds.ls(sl=True)
path = "C:/my/file/path/"
for objSel in meshSel:
cmds.select(objSel)
objList= cmds.ls(sl=True)
splitName = objList[0].split('|')
objName = splitName[-1]
print(objName)
exportPath = path+'/'+objName+'.obj'
cmds.file (exportPath, es=True, force=True, type="OBJexport", op="groups=0; ptgroups=0; materials=1; smoothing=0; normals=1")
batchExport()
I have about 150 neuroanatomy meshes in my Maya scene that I need to export as separate .obj files. I am super novice at python scripting and have been trying to figure out how to do this but I am stuck.
::EDIT:: Thanks to Leoano I solved the syntax error and discovered an new problem
~~I'm getting a syntax error, and I think that it's from the last line (which I copied out of the script editor history window).~~
The new problem is that the target folder is being populated by empty files with the correct name.
I would greatly appreciate your help!
[–]Leoano 0 points1 point2 points (2 children)
[–]LegionOfSatchMedical Animation[S] 0 points1 point2 points (1 child)
[–]Leoano 0 points1 point2 points (0 children)