SAmunategui
12-07-2011, 11:35 PM
I am making part of a script right now and it does what I need but something strange happens and I don't understand why.
It searches through the joints of a skeleton and finds the highest Y positioned joint using xform worldspace
//go through skeleton one by one and store the highest Y translated joint //select all joints in scene
select -r `ls -type joint`;
$jointChain = `ls -sl`;
//go through all the joints and compare world space Y values and store the joint if it's higher than the previous
for ($joints in $jointChain)
{
$jointXForm = `xform -q -ws -t $joints`;
float $jointXFormY = $jointXForm[1];
float $maxYJoint;
string $maxJoint;
if ($jointXFormY > $maxYJoint)
{
$maxJoint = $joints;
$maxYJoint = $jointXFormY;
print ($maxJoint +"\n");
print ($maxYJoint +"\n");
}
}
print ($maxYJoint +"\n");
In the first print (inside the if statement), $maxYJoint is a float. The second time (outside the entire thing) it becomes an int? :hmm:
This is what prints out with the skeleton i'm using right now:
print ($maxYJoint +"\n"); LillianPonyTail2
1.330159945
LillianPonyTail3
1.33016099
Lillian_CenterHead
1.384508372
Lillian_Hair1
1.497386631
Lillian_Hair2 <- correct highest joint name
1.508277113 <- correct highest joint worldspace y value
1 <- ??????
It searches through the joints of a skeleton and finds the highest Y positioned joint using xform worldspace
//go through skeleton one by one and store the highest Y translated joint //select all joints in scene
select -r `ls -type joint`;
$jointChain = `ls -sl`;
//go through all the joints and compare world space Y values and store the joint if it's higher than the previous
for ($joints in $jointChain)
{
$jointXForm = `xform -q -ws -t $joints`;
float $jointXFormY = $jointXForm[1];
float $maxYJoint;
string $maxJoint;
if ($jointXFormY > $maxYJoint)
{
$maxJoint = $joints;
$maxYJoint = $jointXFormY;
print ($maxJoint +"\n");
print ($maxYJoint +"\n");
}
}
print ($maxYJoint +"\n");
In the first print (inside the if statement), $maxYJoint is a float. The second time (outside the entire thing) it becomes an int? :hmm:
This is what prints out with the skeleton i'm using right now:
print ($maxYJoint +"\n"); LillianPonyTail2
1.330159945
LillianPonyTail3
1.33016099
Lillian_CenterHead
1.384508372
Lillian_Hair1
1.497386631
Lillian_Hair2 <- correct highest joint name
1.508277113 <- correct highest joint worldspace y value
1 <- ??????
