PDA

View Full Version : Set CB Filter w/code?


EightBit
01-05-2011, 07:19 AM
Anyone know the code to set the CB to display User Defined Attrs?
I used echo all code in the SE, but it didn't get me there.
Thanks.

pixelranger
01-05-2011, 08:19 AM
you have to set the channelBox display property of the user defined attribute to 'TRUE'.

setAttr -e -channelBox true ( $node + "." + $customAttr);

Keilun
01-05-2011, 02:25 PM
Note that if an attribute is keyable it will always show in the CB regardless of the -channelBox option is true or not. So if you're looking to turn off an attribute, you may need to mark it non-keyable via the setAttr -keyable flag

EightBit
01-06-2011, 09:22 PM
I wasn't clear explaining what I'm trying to do.
I want to display only the UD attrs - the same as when I use the CB menu to show only UD attrs.
I think it would be a filterUI command.
For example, to show all the channels:
filterUIClearFilter mainChannelBox;

Thanks.

pixelranger
01-06-2011, 10:49 PM
try this:
You have to select objects and select channels in the CB that you want to hide. (but, like Keilun said, it will make the non-keyeable.. is that an issue?)


string $sel[] = `ls -l -sl`;
string $mySma[] = `channelBox -q -sma mainChannelBox`;
string $mySsa[] = `channelBox -q -ssa mainChannelBox`;
for ($each in $sel){
for ( $a in $mySma)
setAttr -keyable false -channelBox false ($each + "." + $a);
for ($a in $mySsa)
setAttr -keyable false -channelBox false ($each + "." + $a);
}

pixelranger
01-06-2011, 11:37 PM
Here's how you can filter the channelBox without making the attributes non-keyable.

// filter by scaleRotationTranslate
string $srtFilter = `itemFilterAttr -srt 1`;

// filter by "visibility"
string $visFilter = `itemFilterAttr -bns "visibility"`;

// add the two filters to one (and invert it)
string $udFilter = `itemFilterAttr -union $srtFilter $visFilter -neg 1`;

// and filter the channelBox by this to remove those attributes
channelBox -e -attrFilter $udFilter mainChannelBox;

Maybe you can create a scriptJob checking for selection change and running a procedure in a scriptNode that, when a certain object is selected, runs the above script.

And when anything else gets selected it runs:
channelBox -e -attrFilter 0 mainChannelBox;
to reset the filtering of the channelBox.

CGTalk Moderation
01-06-2011, 11:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.