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.





Leave a Reply

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