Working with fbx files with python in maya

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:

2 Replies to “Working with fbx files with python in maya”

Leave a Reply

Your email address will not be published. Required fields are marked *