Question

I am attempting to control extrusion of an object via rotation of another object in MAYA. But for some reason it's not working. It keeps showing I am getting a syntax error. i am not sure what is wrong with it or how to fix it?

This is the code for it:

int $totalObjects = 1; 
polyPipe -n Rotator -ch on -o on -r 1.839239 -h 1.223879 ;
polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 0.07364761256 -pvy 0.6119394158 -pvz 4.019784712 -divisions 1 -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30 Rotator.f[36];
setAttr "polyExtrudeFace1.localTranslate" -type double3 0 0 0.930651 ;


string $controlName = "Rotator";

float $spacing = 1.5;

for($i=1;$i<=$totalObjects;$i++)
{

 string $outName = ("twist_"+ $i);   
 string $outNameExtrude = ("ext_"+$i);
 float $extrusion = 0;

polyCube -n $outName -ch on -o on -w 12.009218 -h 7.720124 -d 0.755927 -cuv 4 ;
setAttr ($outName+".translateZ") ($spacing*$i);  


expression -s ($extrusion +"= Rotator.rotateY * 0.01*" + ($i*0.5) + ";")  -o "" -ae 1 -uc all ;


polyExtrudeFacet -n $outNameExtrude -constructionHistory 1 -keepFacesTogether 1 -pvx 0 -pvy 0 -pvz 4.0 -r $outName ;
setAttr $outNameExtrude + ".localTranslate" -type double3 0 $extrusion 0 ;


}

UPDATED:

int $totalObjects = 1; 
polyPipe -n Rotator -ch on -o on -r 1.839239 -h 1.223879 ;
polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 0.07364761256 -pvy 0.6119394158 -pvz 4.019784712 -divisions 1 -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30 Rotator.f[36];
setAttr "polyExtrudeFace1.localTranslate" -type double3 0 0 0.930651 ;


string $controlName = "Rotator";

float $spacing = 1.5;

for($i=1;$i<=$totalObjects;$i++)
{

 string $outName = ("twist_"+ $i);   
 string $outNameExtrude = ("ext_"+$i);
 float $extrusion = 0;

polyCube -n $outName -ch on -o on -w 12.009218 -h 7.720124 -d 0.755927 -cuv 4 ;
setAttr ($outName+".translateZ") ($spacing*$i);  



polyExtrudeFacet -n $outNameExtrude -constructionHistory 1 -keepFacesTogether 1 -pvx 0 -pvy 0 -pvz 4.0 $outName ;
setAttr ($outNameExtrude + ".localTranslate") -type double3 0 $extrusion 0 ;


expression -s ( $outNameExtrude + ".O[0]" +"= Rotator.rotateY * 0.01*" + ($i*0.5) + ";")  -o "" -ae 1 -uc all ;


}
Was it helpful?

Solution

As pointed out by @theodox. You should never rely on Maya setting the name you told it to set. Because if Maya has a naming clash, etc. than maya will override you so whenever you create something always catch the name. So for example

polyExtrudeFacet -n $outNameExtrude 
                 -ch 1 -keepFacesTogether 1 
                 -pvx 0 -pvy 0 -pvz 4.0 $outName;

Should be:

$tmp = `polyExtrudeFacet -n $outNameExtrude
                         -ch 1 
                         -keepFacesTogether 1 
                         -pvx 0 -pvy 0 -pvz 4.0 
                          $outName` ;
 $outNameExtrude = $tmp[0];

This saves you form Maya blowing up in your face. So your code would look like:

proc makeCubesDrivenBy(
    string $controlName, int $totalObjects, float $spacing
    ){

    for($i=1;$i<=$totalObjects;$i++)
    {
        string $tmp[];
        string $outName = ("twist_"+ $i);   
        string $outNameExtrude = ("ext_"+$i);
        float $extrusion = 0;

        $tmp = `polyCube -n $outName -ch 1
                 -o on -w 12.009218 
                 -h 7.720124 -d 0.755927
                 -cuv 4`;
        $outname = $tmp[0];
        setAttr ($outName+".translateZ") ($spacing*$i);  

        $tmp = `polyExtrudeFacet -n $outNameExtrude
                                 -ch 1 
                                 -keepFacesTogether 1 
                                 -pvx 0 -pvy 0 -pvz 4.0 
                                 $outName` ;
        $outNameExtrude = $tmp[0];
        setAttr ($outNameExtrude + ".localTranslate") 
                  -type double3 0 $extrusion 0 ;


        expression -s ( $outNameExtrude + ".tz" +
                        "= Rotator.rotateY * 0.01*" +
                       ($i*0.5) + ";")  -o "" 
                       -ae 0 -uc all ;
    }
}

{
    string $pipe[], $facet[];
    int $totalObjects = 1; 
    $pipe = `polyPipe -n Rotator -ch 1 
             -o on -r 1.839239 
             -h 1.223879` ;
    $facet = `polyExtrudeFacet -ch 1 -keepFacesTogether 1
                     -pvx 0.07364761256 
                     -pvy 0.6119394158 
                     -pvz 4.019784712 
                     -divisions 1 -twist 0 
                     -taper 1 -off 0 
                     -smoothingAngle 30 Rotator.f[36]`;
    setAttr ($facet[0] + ".localTranslate") 
            -type double3 0 0 0.930651 ;
    makeCubesDrivenBy($pipe[0], 1 , 1.5);
}

Anyway the process itself isnt really sane as you copy history inputs but I can not really guess what you are after.

PS: dont use -ae 1 in expressions unless you really have to, and you dont.

OTHER TIPS

Your expression is

0= Rotator.rotateY * 0.01*0.5;

which doesn't work. Do you want ".O[0]" instead ?

You also have a -r flag in your polyExtrudeFacet; I don't think that works.

Finally, you should bracket $outNameExtrude + ".localTranslate" in the last line;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top