Friday, June 22, 2018

Maya 2018 Time Editor Batch import fbx

I'm doing a thing that requires the import of multiple FBX files into the Time Editor.  The time editor is this sort of non-linear animation editing system that's now available in Maya.  If this plan work  out, I will need to import about 200 animation files.  Since the file/import can only handle one file at a time, I decided to make a little script.  This is super basic at the moment, but may provide a launchpad for further refinement.

import pymel.core as pm

def multiFbxTimeEditImporter():    
    """Stub function for batch importing fbx files to the Time Editor    
    :return:    
    """    
    basicFilter = "*.fbx"    
    result = pm.fileDialog2(fileFilter=basicFilter, fileMode=4, dialogStyle=2)

    for r in range(len(result)):        f = result[r]
        nn = result[r].rpartition('/')[2].replace('.fbx', '')
        ntrack = pm.timeEditorTracks('Composition1', edit=True, addTrack=-1, 
        trackType=0, trackName=nn)

        pm.timeEditorClip(nn, importFbx=f, importOption="generate", 
        ipo="cuves", importAllFbxTakes=True,                          
        importTakeDestination=r, track='Composition1|'+nn)