comp_attrs

MPlugs: Compound Plugs

Compound plugs are useful for organizing a bunch of MPlugs into a single group. I like to use them in tools that need to store persistent data in Maya scene files.

To create a compound plug we use MFnCompoundAttribute. The actually creation process is similar to my previous example on creating plugs. Lets get started.

First we’ll create a node to add the compound plug to.

Now to make the MPlugs that will be children of the compound plug.

The compound plug is made in a similar fashion only it doesn’t require a data type to be specified at creation. Since this plug will have multiple children we need to set it to an array.

Adding the children plugs to the compound.

And finally, we add the compound to the network node we created at the beginning.

comp_attr

 

comp_attr2

Here’s the whole thing together.