fbx, or fbx(why are you such a pain?)

Working with fbx files in maya using python isn’t the most frustrating format to work with, just very picky.

When using python, try to stay away from using maya file command:

You can by all means use that command, but it’s buggy when you want to have certain options for your import. i.e. if your open file preferences are set to maya native compared to os native, the fbx import options windows doesn’t always come up before import.

A better way is to use maya.mel commands for fbx:

Strange right?

The way fbx code works is kinda like building up what you want for options and then importing your file.

It would make more sense to have a command with options built into it, i.e:

Alas, we can’t have something nice to work with. Now, since we are using mel commands in python, we need a way to transfer between python and mel variables.

To store python data in a mel variable we can use:

To store mel data in a python variable we can use:

Now that’s all fine and dandy, but we are working with python from the start. So we need a way to store a python variable in mel, from python.

So, to do that:

So we can finally put it all together in a python function:

You can find references for commands here:
http://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/GUID-699CDF74-3D64-44B0-967E-7427DF800290-htm.html