PDA

View Full Version : check if attribute is hidden


vvkonline
01-18-2010, 01:02 AM
Hi all,
I'm trying to see if a specific attributes are hidden on a specific object.
I was trying this: but not sure why it gives same result if attribute hidden or not.

string $loc[] = `spaceLocator` ;
attributeQuery -node $loc[0] -hidden "tx";
// Result: 0 //
setAttr -lock true -keyable false -channelBox false ($loc[0]+".tx");
attributeQuery -node $loc[0] -hidden "tx";
// Result: 0 //

BigRoyNL
01-18-2010, 08:45 AM
I don't know why it's not working. I think the way you wrote it down should work (tried it here, but didn't work either). Must be some way or another misinterpreting the way the command works.

A way that works is checking if the attribute is visible in the channel box.

getAttr -cb ($loc[0]+".tx")

Note: This returns 1 if it's in the channel box (unhided) and 0 if it's hidden.

Keilun
01-18-2010, 02:57 PM
The 'hidden' attribute characteristic is not synonymous with "is it present in the channel box?"

The hidden characteristic means it is hidden from most UIs and can usually only be accessed via MEL, the API or internal routines. I don't believe you can actually set an attribute to hidden after attribute creation. It's something that is defined at creation time - and likely only through the API.

If you're looking to query whether or not it is visible in the channel box then you want to check if the attribute is keyable as well as the getAttr -cb (since some non-keyable attributes can be forced to the channel box as well).

vvkonline
01-18-2010, 03:48 PM
cool, thank you but again in this case
getAttr -cb ($loc[0]+".tx"); it always returns 0, if it's in channel box or not.

getAttr -k ($loc[0]+".tx"); does return 1 or 0

Byterunner
01-18-2010, 04:45 PM
It appears that an attribute can have either "keyable" or "channelBox" as true, but never both, though they can both be false.

// default tx keyable 1, default tx channelBox: 0
setAttr -k 0 -cb 0 ($loc[0]+".tx");
// tx keyable 0, tx channelBox : 0
setAttr -k 1 ($loc[0]+".tx");
// tx keyable 1, tx channelBox : 0
setAttr -cb 1 ($loc[0]+".tx");
// tx keyable 0, tx channelBox : 1

But if you switch the last two lines

// default tx keyable 1, default tx channelBox: 0
setAttr -k 0 -cb 0 ($loc[0]+".tx");
// tx keyable 0, tx channelBox : 0
setAttr -cb 1 ($loc[0]+".tx");
// tx keyable 0, tx channelBox : 1
setAttr -k 1 ($loc[0]+".tx");
// tx keyable 1, tx channelBox : 0

If an attribute is keyable, it is always visible in the channelBox, even though it automatically sets the -channelBox value to false.

Keilun
01-18-2010, 05:32 PM
I think there is some confusion about the -channelBox flag. It is specifically meant to allow non-keyable attributes visibility in the channelBox. It is not meant as an ability to disable the visibility of a keyable attribute in the channel box.

This is more specifically defined in the setAttr -cb documentation, where it states:

Sets the attribute's display in the channelBox on or off. Keyable attributes are always display in the channelBox regardless of the channelBox settting.

So the proper test is:

global proc int isVisibleInChannelBox( string $attr )
{
int $ret = 0;
int $isKeyable = `getAttr -k $attr`;
int $isChannelBox = `getAttr -cb $attr`;
if( $isKeyable || $isChannelBox )
{
$ret = 1;
}
return $ret;
}

vvkonline
01-18-2010, 06:14 PM
if it's keyable it's in channel box,
if it's not keyable it can be in channel box, but it also can be hidden.

Thank you for taking your time.

CGTalk Moderation
01-18-2010, 06:14 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.