Getting information on MotionBuilder’s Python with dir

Trying to figure how things work in MotionBuilder’s Python editor is tough. Google and the SDK Help that comes along with MotionBuilder are great, but there is still more help out there – the “dir”! 🙂

What does “dir” do? The definition I was able to find is “It gives you an alphabetical listing of valid attributes”. It’s so much easier to show you what it does than it is to explain.

Here we will use “dir” to see all the attributes on the object FBApplication():

from pyfbsdk import *

# Set variable for FBApplication.
lApp = FBApplication()

# print out the dir
print dir(lApp)


Here we can see the results of the print the dir() command.

From here we can see that there is an attribute for “CurrentCharacter”. If I open up the scene “mia_rigged.fbx” we can then do something like:

from pyfbsdk import *

print dir(FBApplication().CurrentCharacter)

Now that all the attributes are listed for the Mia Character, we can see that there is one called “MirrorMode”.

With that exposed we could setup a script that will mirror animation in MotionBuilder with ease (which you can find here).
This is a great way to find or explore within python.

I like to have the below snippet of code near by when I am trying to figure out things:


# create a variable lGetInfor - pastehere = paste the object you want to list the attributes of
lGetInfor = pastehere
print dir(lGetInfor)

\

I hope this helps.

3 Comments

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.