View Single Post
# 1 11-07-2014 , 02:50 PM
baguzie2's Avatar
bca
Join Date: Jul 2014
Location: Austin, Texas
Posts: 9

Error: Cannot convert data type float to type float

This is a script for cloning a tank tread. I got it from a tutorial but applying it on different model. I tried to make sure that names of the elements in the rig are exactly the same with the tutorial model. But when I run it I get this error message: "Cannot convert data type float to type float". I simply stuck as I do have knowledge of scripting. I really need help please.

////Tread Cloning Tool////
//Instructions: select inital tread and run code!

///First, find width of tread and length of curve///

//Get selection...
string $sel_srcTread[] = `ls -sl`;
//Find selection's shape node...
string $shp_sel_o[] = `listRelatives -type shape $sel_srcTread[0]`;
//Use tread's bounding box to find its width...
float $tread_bbs = `getAttr ($shp_sel_o[0] + ".boundingBoxSizeX")`;
//Get length of path curve...
float $cLen = `getAttr cInfo_r_treads01.arcLength`;
//This will help us to populate our path with enough treads....
float $trd_quantity = ($cLen / $tread_bbs) - 1;


///Next, evenly space each created tread along its path///

//Calculate difference between the total tread length and the curve length...
float $size_of_gap = ($cLen % $tread_bbs);
//This finds each tread's offset...
float $each_trd_offset = $size_of_gap / $trd_quantity ;
//Each tread needs to take up this much space...
float $each_trd_spacing = $tread_bbs + $each_trd_offset;

///Finally, create a for loop to generate and constrain each tread///

//$i = our cloning range...
for ($i = 1; $i <= $trd_quantity; $i++) {
//Instance each tread and rename with prefix "dup_" to keep track of clones...
string $this_tread[] = `instance -lf -n ("dup_" + $sel_srcTread[0]) $sel_srcTread[0]`;
//Path constrain each tread to a defined path...
string $this_path = `pathAnimation -n ("mPath_" + $this_tread[0]) -fractionMode true -follow true -followAxis x -upAxis y -worldUpType "object" -worldUpObject "locUpVct_r_treads01" -inverseUp true -inverseFront false -bank false -c "cPath_r_treads01" $this_tread[0]`;
//Remove all animation nodes from cloned treads so we can control each motion path's "uValue"...
select ($this_path + "_uValue"); doDelete;
// This evenly places every tread in 0...1 space to match motion path's 0...1 space...
float $trd_spacing = ($each_trd_spacing * $i) / $cLen;
//Variable "$this_expression" holds the expression needed to drive each tread...
string $this_expression = ( "float $u = (((cPath_r_treads01.tz * anim_r_treads01.active + anim_r_treads01.offset) * anim_transport_global01.scaleY)/cInfo_r_treads01.arcLength);" + "\n" + $this_path + ".u" + " = ( 1 + ( " + $trd_spacing + " + (1-($u))%1))%1;" ) ;
//This creates the expression needed for each tread...
expression -n ($this_path + "_expr") -s $this_expression;
}