Compute not working Maya api

Just a tip:

If you find your compute function not firing like it should. Double check that your output attributes are NOT set to keyable.

What a pain that was.

Working with Maya’s python api – The compound attribute

Continuing my explanation of maya’s python api, we come to the compound attribute.

This is a handy way to organize our arrays.

First we create our MFnCompoundAttribute class:

Then we create an input array(we are using matrix as input) so let’s create that class.

Then create our matrix array attribute that will be a child of our compound attribute:

Next, we can create our ‘parent’ compound attribute:

As you can see, we created a compound attribute with our inputs array set to be the child.

This creates a hierarchy that would make sense:


Next we will look at how to get the data from each plug when we need it:

-Note, I found this very confusing when I first tried to do this correctly. Explanations are in the code as comments:

I hope you find this helpful.





Working with Maya’s python api – The enum attribute

Here is some information on creating a enum attribute in maya python api.


Let’s start on creating an enum attribute that will work like an optionMenu.

First we create our enum class:

Then we can add our attribute to the class:

Next we can add some ‘fields’ to the attribute. This is where we add the options to our optionMenu:

There,  now we have 5 options available to choose from. When queried, we will get an int in return.

Next let’s set up some options in the MFnEnumAttribute class:

We want to be able to key the option we want, and we want to be able to have current option save to the file.

Last, we need to add our newly created attribute to the node we are working on:

The whole code for this enum attribute:


Next, lets look at how to get at our optionMenu when we need to:

When we want to get at the data, we need to create a dataBlock:

The variable ‘optionMenu_value’ now contains the data we want. We can use it like this:

This is an easy way to add a little option box to our plugin.

New Adventure!

Finally made full-time as Character Technical Artist @ Suckerpunch Productions. Time to get to work!