PDA

View Full Version : Group a joint


nottoshabi
03-10-2011, 04:05 AM
I'm trying to group a joint and set the world position of that joint to the group so I can have 0 on translates and rotates. I can query the joint translate I just can not set it to the group. This is what I got so far, but I'm getting an error.

// Error: setAttr: Error reading data element number 1: //

I know is from this line ( setAttr ($Grp[0] + ".translate") $pos; )


//grp
string $Grp[] = `ls-sl`;
//jnt
string $Jnt[] = `ls-sl`;
//Get translate of joint
float $pos[] = `xform -q -ws -t $Jnt[0]`;
//setAttr to grp
setAttr ($Grp[0] + ".translate") $pos;
//reset joint to 0 0 0
setAttr ($Jnt[0] + ".translate")0 0 0;

ginodauri
03-10-2011, 05:00 AM
setAttr -type "float3" ($Grp[0] + ".translate") $pos[0] $pos[1] [2];

I hink only boolean , integer , and single float work without type declaration.

For every other you need to specify attribute type.

NaughtyNathan
03-10-2011, 08:54 AM
no, setAttr doesn't need type declaring in cases like this, it just doesn't accept an ARRAY and $pos is an array.

float $pos[] = `xform -q -ws -t $Jnt[0]`;
setAttr ($Grp[0] + ".translate") $pos[0] $pos[1] $pos[2];you were basically correct Ginodauri, but just for the slightly wrong reason! ;)

:nathaN

ginodauri
03-10-2011, 01:01 PM
Ok my mistake.

In past i was in simmilar situation but dealing with other attr types , and probably get in habit of specifying attr types.

nottoshabi
03-10-2011, 05:20 PM
So what I was missing was to the declare XYZ of $pos by adding $pos[0] $pos[1] $pos[2]?

giordi
03-11-2011, 01:55 PM
well remeber that if you get ws space coordinates you gotta reset them in with ws flag on. you can do that with xform

CGTalk Moderation
03-11-2011, 01:55 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.