View Full Version : Group a joint

03 March 2011, 05: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; )

string $Grp[] = `ls-sl`;
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;

03 March 2011, 06: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.

03 March 2011, 09: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! ;)


03 March 2011, 02: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.

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

03 March 2011, 02: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 March 2011, 02: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.