View Single Post
# 11 15-07-2014 , 12:42 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
The error you were getting on line 11 was actually:

Code:
Cannot convert data of type float[] to type float
The square brackets were missing from your original question and that confused me quite a bit. The error means that whatever you're trying to query returns a list of values and needs to be stored in an array. Easy solution for that.

Code:
/* Turn the original float var into a float array 
 with a slightly altered name.
 Declare a new float with the original name so you don't have to
 alter the variable in the rest of the script.
 Assign the variable a value from the list, I just chose the first one.

*/
float $tread_bbs1[] = `getAttr ($shp_sel_o[0] + ".boundingBoxSizeX")`;
float $tread_bbs = $tread_bbs1[0];
Then there is the issue of the expression complaining about cPath_r_treads01.tz, anim_r_treads01.active(there's a typo, the 'a' in active needs to be upper case) and anim_r_treads01.offset. Maya didn't know what to do with these three so I had to get the attribute values, the `` evaluates the enclosed command and returns a usable value.

Code:
string $this_expression = ( "float $u = (((`getAttr cPath_r_treads01.tz` * `getAttr anim_r_treads01.Active` + `getAttr anim_r_treads01.offset`) * anim_transport_global01.scaleY)/cInfo_r_treads01.arcLength);" + "\n" + $this_path + ".u" + " = ( 1 + ( " + $trd_spacing + " + (1-($u))%1))%1;" ) ;
It works.

user added image

Download
tankThreadGenerator


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::