Attribute Divider Tool

Whilst setting up a rig in Maya, as I'm sure you know its nice to keep things in the channel box of your controls organised and pretty. So I set out to create a well rounded utility tool that will help make this aspect of rigging a little cleaner and quicker.

Now firstly we need to address a little problem introduced by the Channel box within Maya. This is the fact that you cannot have attributes with matching names on the same object. This is what makes this task a little more tricky than just running an addAttr command every time the button is pressed.

To get around this I came up with a stable method of creating a unique name for every added attribute regardless of how many the user would like to add.


Within this proc I start off with checking if the user has selected anything and if not warning them to please select something. Now the fun part. Using the command

string $AtrEx[] = `listAttr - ud`;

 will return a string with all the user defined attributes that have been added to that object. Following this using the size command we can turn the sting into an integer. Now all we do is add a new attribute with the name "Divider" + whatever number of custom attributes already exist on said control. TaDa, we have a stable way of continually adding new attributes without ever having a conflict.

Feel free to grab a copy of this script from my Gist account and use as you'd like. I'll probably expand on this tool in the near future and add some more functionality.

https://gist.github.com/JustinPedersen/72425332376be460f89be3b5b056bff5


- Sheep



Comments

Popular Posts