PDA

View Full Version : setAttr


xcomb
10-16-2006, 12:11 PM
Hi All!
I didn't have much time to learn mel, so i am asking, for your help.
I have character animated and i want to enable on all joints the visibility and keyable attributes.
I have written this small script, which doesn't seems to work for good reason. :)
I know i can enable through chanel editor, but that's not what i am looking for.
Please point me into the right place!

string $joints[] = `ls -type "joint"`;

float $size = size($joints);
string $listAttr[] = `listAttr -v -keyable $joints`;

for($each in $joints)
{
setAttr -k true ($joints[$i] + "." + $listAttr[$i]);
}



Thanks!

Robert Bateman
10-16-2006, 12:28 PM
string $joints[] = `ls -type "joint"`;

for($joint in $joints)
{
string $listAttr[] = `listAttr -v -keyable $joint`;
for($attr in $listAttr)
{
setAttr -k true ($joint + "." + $attr);
}
// set visibility
setAttr ($joint+".visibility") true;
}

xcomb
10-16-2006, 01:33 PM
Thanks!
Makes sence to me now.

One thing is weired to me, that those hidden attributes don't show up, i cannot listAttr on them, get result is 0
I was able to hide attributes, but not to show them back :(
I've tryed alll flags, i have Maya 8.

string $joints[] = `ls -type "joint"`;

for($joint in $joints)
{
string $listAttr[] = `listAttr -v -keyable $joint`;
for($attr in $listAttr)
{
setAttr -k true ($joint + "." + $attr);
}
// set visibility
setAttr ($joint +".visibility") true;
}

Robert Bateman
10-16-2006, 04:33 PM
the -v flag to listAttr means it only returns visible attrs, remove that flag and it should work (ish). You might get a few oddities though

xcomb
10-16-2006, 06:22 PM
the -v flag to listAttr means it only returns visible attrs, remove that flag and it should work (ish). You might get a few oddities though

Unfortunatly it doesn't work, i did remove all flags and -v flag, same deal

string $joints[] = `ls -type "joint"`;

for($joint in $joints)
{
string $listAttr[] = `listAttr -keyable $joint`;
for($attr in $listAttr)
{
setAttr -k true ($joint + "." + $attr);
}
// set visibility
setAttr ($joint +".visibility") true;
}
only Visibility works.

isoparmB
10-17-2006, 05:38 AM
If you know the attributes you want to reactivate, you should just indicate them in the script. If an attribute is not in the channelbox, it will not be keyable, hence you won't be able to query them as keyable attributes.

string $joints[] = `ls -type "joint"`;
string $attributes[] = {".tx", ".ty", ".tz", ".rx", ".ry", ".rz", ".sx", ".sy", ".sz", ".v"};
string $joint;
string $attribute;

for($joint in $joints)
{
for($attribute in $attributes)
{
setAttr -lock false -keyable true ($joint + $attribute);
};
};

xcomb
10-17-2006, 07:21 AM
Ohh i c why.
Thanks a lot!

CGTalk Moderation
10-17-2006, 07:21 AM
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.