PDA

View Full Version : Creating null groups on joints


PozestStar
11-09-2011, 08:15 AM
This is part of a larger script.

The idea is to create and snap an empty group to how many ever joints are in your selection. I can't get it to work. (If you can't tell, I'm still figuring out the basics of MEL). Could someone tell me (and explain to me) why this doesn't work? I tried the same thing with locators and it works.

Also, if there's an easier/better/more efficient way to do this, I'm all ears. I tried to do this with xform but... :cry:

Thank you!!

(this works)

global proc Stretchy(){
string $jntCol[] = `ls -sl -type joint`;
string $jnts;

for ($jnts in $jntCol){
select $jnts;
string $sLoc[] = `spaceLocator -n ($jnts + "_stretchLoc")`;
string $ptCnLoc[] = `pointConstraint $jnts $sLoc`;
string $orCnLoc[] = `orientConstraint $jnts $sLoc`;
delete $ptCnLoc $orCnLoc;
select $jnts;
}
}


This doesn't.


global proc Stretchy(){
string $jntCol[] = `ls -sl -type joint`;
string $jnts;



for ($jnts in $jntCol){

string $sNull[] = `group -em -n ($jnts + "_stretchNull")`;

string $ptCnNull[] = `pointConstraint $jnts $sNull`;

string $orCnNull[] = `orientConstraint $jnts $sNull`;

delete $ptCnNull $orCnNull;

select $jnts;
}
}

Gidsche
11-09-2011, 08:49 AM
Hej.....

...a group command doesn`t return a stringarray but a string....so replace this line:

string $sNull[] = `group -em -n ($jnts + "_stretchNull")`;

by this one and it will work

string $sNull = `group -em -n ($jnts + "_stretchNull")`;


An easier way would be to query the rotatePivot of the jnts like this

global proc Stretchy()
{
string $jntCol[] = `ls -sl -type joint`;
for ($jnts in $jntCol){
string $sNull = `group -em -n ($jnts + "_stretchNull")`;
float $jntpivot[] = ` xform -q -ws -rp $jnts`;
move -a $jntpivot[0] $jntpivot[1] $jntpivot[2] $sNull;
}
}




...since this is my 2nd reply i think someone else will give an answer to this earlier than my post will be validated ;-)


Cheers...

NaughtyNathan
11-09-2011, 10:34 AM
the error it returns should tell you the problem:

// Error: line 9: Cannot convert data of type string to type string[]. //

the `group` command returns a single string, and you have it capturing into an array ($sNull[]) presumably becasue you converted the code from when it was locators, and the spaceLocator command does return an array.

:nathaN

PozestStar
11-09-2011, 04:39 PM
Thanks so much! That was the problem.

CGTalk Moderation
11-09-2011, 04:39 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.