Home Technical Talk

Anyone know of a .ma batch exporter for Maya?

polycounter lvl 12
Offline / Send Message
Hayden Zammit polycounter lvl 12
Hey guys,

Do any of you know of any batch exporters for maya that can export out a bunch of selected files and into separate .ma files that are named what the objects were called in the outliner?

Setting up a reference library, and it'd be pretty handy. I've seen a few that will do FbX, but I need .ma.


cheers.

Replies

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Here ya go. Nothing fancy. If the scene is saved, it creates a folder called Batch_Exports and exports it there. If the scene is not saved, it prompts for a directory to save in. Ran some basic tests on it and worked so let me know if something bugs out for you. Also this is Python code btw as a headsup
    import maya.cmds as cmds
    
    selection = cmds.ls(sl=True)
    manualSave = False
    if len(selection) != 0:
        fileName = cmds.file(query=True,sn=True)
        if fileName == "":
            try:
                filePath = cmds.fileDialog2(fileMode=3, dialogStyle=2,caption="Scene was not saved. Select Directory to export.")[0]
                manualSave = True
            except TypeError:
                cmds.warning("Aborted by user.")
        else:
            filePath = fileName.rpartition('/')[0]
        for object in selection:
            cmds.select(object)
            if manualSave:
                path = "%s/%s.ma" % (filePath,object)
                cmds.file(path,es=True,force=True,typ="mayaAscii")
            else:
                directoryPath = "%s/Batch_Exports" % (filePath)
                cmds.sysFile( directoryPath, makeDir=True )
                path = "%s/%s.ma" % (directoryPath,object)
                cmds.file(path,es=True,force=True,typ="mayaAscii")     
    else:
        cmds.error("Nothing selected")
    
  • Hayden Zammit
    Options
    Offline / Send Message
    Hayden Zammit polycounter lvl 12
    Whoa, so you're a wizard then, yeah?

    Thanks a a lot for this. Before I had to export one asset at a time and it just took too long.

    So awesome. Thanks again!
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Ha! Far from it :P No problemo, always glad to help people with scripts and whatnot been doing too much maxscripting :(
Sign In or Register to comment.