"Error: Cannot convert data of type float[] to type float" ?

"Error: Cannot convert data of type float[] to type float" ?

Anonymous
Not applicable
3,752 Views
1 Reply
Message 1 of 2

"Error: Cannot convert data of type float[] to type float" ?

Anonymous
Not applicable

For my script, I am using a function that collects the world space transform values from an object.  I'm getting a "Cannot convert data of type float[] to type float" error when executing a function for a specific part of my script.  I don't know why this error occurs as I have labeled my data types correctly.

 

Part of the script that uses the function:

 

        string $jointChildren[], $startJoint, $endJoint;
        float $startTrans[], $endTrans[];       
        
        $startJoint = "joint1";        
        $jointChildren = `listRelatives -ad $startJoint`;   
        $endJoint = $jointChildren[0];
             
        $startTrans = `getTransform($startJoint)`;
        $endTrans = `getTransform($endJoint)`;
        
        print($startTrans);
        print($endTrans);
                    
        makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
        joint -e  -oj xzy -secondaryAxisOrient zup -ch -zso;
        createIKSpline($selJoints[0], $selJoints[1]);

The function that it calls:

 

 

// Get the transform values of an object
global proc float[] getTransform(string $obj) {
    float $xTrans = `getAttr $obj.translateX`;
    float $yTrans = `getAttr $obj.translateY`;
    float $zTrans = `getAttr $obj.translateZ`;
    float $trans[3] = {$xTrans, $yTrans, $zTrans};
    
    return $trans;
}

 

 

0 Likes
Accepted solutions (1)
3,753 Views
1 Reply
Reply (1)
Message 2 of 2

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Try This.

Select start and end joint for the ikSpline and run the script.

// Get the transform values of an object
global proc float[] getTransform(string $obj) {
float $xTrans = `getAttr ($obj+".translateX")`;
float $yTrans = `getAttr ($obj+".translateY")`;
float $zTrans = `getAttr ($obj+".translateZ")`;
float $trans[2] = {$xTrans, $yTrans, $zTrans};

return $trans;
}

string $selJoints[] = `ls -sl`;
string $jointChildren[], $startJoint, $endJoint;
float $startTrans[], $endTrans[];

$startJoint = "joint1";
$jointChildren = `listRelatives -ad $startJoint`;
$endJoint = $jointChildren[0];

$startTrans = `getTransform($startJoint)`;
$endTrans = `getTransform($endJoint)`;

print($startTrans);
print($endTrans);

makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
joint -e -oj xzy -secondaryAxisOrient zup -ch -zso;
//createIKSpline($selJoints[0], $selJoints[1]);
ikHandle -sol ikSplineSolver -sj $selJoints[0] -ee $selJoints[1];
0 Likes