Hi! I working on a oil refinery model so I'm trying to make an automatic pipe script. This is my first attempt at MEL and I have the first part working.
I need to know how to evaluate the axis of a single face and then compare to some xyz coords to change direction. something like this:
if (selected Face AXIS) xyz = 0 1 0 then set corner rotation to z;
if (selected Face AXIS) xyz = 1 0 0 then set corner rotation to y;
etc...
I just can't figure what commands to use to get the (selected Face AXIS) xyz, AND compare it to my own xyz (0 1 0) options.
I want to create hot keys for extrude and corners of a pipe, sort of like the MS Windows pipe screen saver. here's the first part of the script that will make a corner pipe in one direction:
// select the top single face of a cylinder, it will make a 90 degree corner pipe. float $TransZ; $TransZ = 2; // size of bend string $strSelObj[] = ls -sl; { for ($laps = 0; $laps <= 3; $laps++ ) // number of bend sections { polyExtrudeFacet -keepFacetTogether true -localTranslateZ $TransZ -lry 22.5; // rotate sections to 90 } }
however, it returns a formatted string array (for some dumb-ass reason) so you'll need to tokenize it... CODE { string $fNormal[] = polyInfo -fn pCylinder1.f[17]; string $tokens[5]; tokenize $fNormal[0] $tokens; vector $FN = <>; }
it's really important that you understand scope if you want to use MEL effectively. any variable declared after an open curly brace { ONLY EXISTS inside that block of braces. when the block is closed with a close brace } ALL THOSE variables inside are destroyed.
$varB and $varC now no longer exist, whereas $varA does, because it was declared OUTSIDE the curly braces. also, you must always refer to vectors using the correct syntax for vectors <>
if ($FN = <>) print "worked!";
hope this helps sort you out (but this basic stuff is all explained really well and very clearly in Maya's built-in MEL docs...) :nathaN