berniebernie
12-07-2008, 04:24 PM
Hello cgtalkers
I'm writing a small proc that will create x joints on a curve, but I'm failing in the for loop, and I can't figure out why.
Basic procedure:
- create a joint, stored in a var
- parent the joint to the previous joint
- next iteration of the for loop: make the new joint the 'old' joint and start over till the loop ends
Big ass screenshot:
http://mlkdesign.free.fr/dump/screenshotforloop.gif
Here's the code i wrote
global proc createJointsOnCurve(int $jointnum){
$sel = `ls -sl`;
$obj = $sel[0];
float $startpos[] = `pointOnCurve -pr 0 -p $obj`;
string $oldjoint = `joint -p $startpos[0] $startpos[1] $startpos[2]`; //starting joint
string $newjoint = "";
for($a = 0;$a<=$jointnum;$a++){
print("Start /// old: "+$oldjoint+" nu: "+$newjoint+"\n");
$currentUPos = $a/$jointnum;
float $jointpos[] = `pointOnCurve -pr $currentUPos -p $obj`;
$newjoint = `joint -p $jointpos[0] $jointpos[1] $jointpos[2]`;
joint -e -zso -oj xyz -sao yup $oldjoint;
string $oldjoint = $newjoint;
print("End /// old: "+$oldjoint+" nu: "+$newjoint+"\n");
}
}
createJointsOnCurve(10);
What did I do wrong ?
( in the script editor window, it's always printing 'joint 34', doesn't iterate)
I'm writing a small proc that will create x joints on a curve, but I'm failing in the for loop, and I can't figure out why.
Basic procedure:
- create a joint, stored in a var
- parent the joint to the previous joint
- next iteration of the for loop: make the new joint the 'old' joint and start over till the loop ends
Big ass screenshot:
http://mlkdesign.free.fr/dump/screenshotforloop.gif
Here's the code i wrote
global proc createJointsOnCurve(int $jointnum){
$sel = `ls -sl`;
$obj = $sel[0];
float $startpos[] = `pointOnCurve -pr 0 -p $obj`;
string $oldjoint = `joint -p $startpos[0] $startpos[1] $startpos[2]`; //starting joint
string $newjoint = "";
for($a = 0;$a<=$jointnum;$a++){
print("Start /// old: "+$oldjoint+" nu: "+$newjoint+"\n");
$currentUPos = $a/$jointnum;
float $jointpos[] = `pointOnCurve -pr $currentUPos -p $obj`;
$newjoint = `joint -p $jointpos[0] $jointpos[1] $jointpos[2]`;
joint -e -zso -oj xyz -sao yup $oldjoint;
string $oldjoint = $newjoint;
print("End /// old: "+$oldjoint+" nu: "+$newjoint+"\n");
}
}
createJointsOnCurve(10);
What did I do wrong ?
( in the script editor window, it's always printing 'joint 34', doesn't iterate)
