//******************************************************************************************** //******************************************************************************************** //*** *** //*** PIPE v2.0 © XAVIER GOUCHET 2006 *** //*** *** //*** *** //******************************************************************************************** //******************************************************************************************** // // // DESCRIPTION: // it takes a nurbs curve and extrude a circle along this curve. // the circle is placed and oriented by this script. // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // AUTHOR : // Xavier Gouchet , 2006 // http://xgouchet.fr/ // xavier.gouchet@gmail.com // // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // INSTALLATION: // // place the "pipe.mel" script in your script directory // defaults : // OSX : ~/Library/Preferences/AliasWavefront/maya/scripts/ // Windows : My Documents/maya/scripts/ // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // USAGE: // Select the curve you want to pipe and run the following command // pipeWindow(); // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // v2.0 (January 18, 2006) // - more control on extrusion // - more accurate orientation of the circle // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // // Please report bugs, suggestions, comments or others at // xaebhal@hotmail.com // global proc genPipe (float $radius, float $scale){ $sel = `ls -sl -fl`; float $attrVal; for ($s in $sel){ // first we create a base circle to extrude $circleName = $s+"_circle"; circle -c 0 0 0 -nr 0 1 0 -sw 360 -r $radius -d 3 -ut 0 -tol 0.01 -s 8 -ch 1; rename $circleName; //Then we place it at the beginning of the curve $firstCV = $s+".cv[0]"; $secondCV = $s+".cv[1]"; select -r $firstCV; $CVCoords1 = `xform -q -t $firstCV`; select -r $secondCV; $CVCoords2 = `xform -q -t $secondCV`; select -cl; move -a $CVCoords1[0] $CVCoords1[1] $CVCoords1[2] $circleName; // then we place it to be Perpendicular to the start normal of the curve $circleCreate = $circleName+".create"; $connections = `listConnections -s on $circleCreate`; $makeCircle = $connections[0]; $theAttr = $makeCircle + ".normalX"; $attrVal = $CVCoords2[0] - $CVCoords1[0]; setAttr $theAttr $attrVal; $theAttr = $makeCircle + ".normalY"; $attrVal = $CVCoords2[1] - $CVCoords1[1]; setAttr $theAttr $attrVal; $theAttr = $makeCircle + ".normalZ"; $attrVal = $CVCoords2[2] - $CVCoords1[2]; setAttr $theAttr $attrVal; // finnaly we extrude it extrude -ch true -rn true -po 0 -et 2 -ucp 0 -fpt 1 -upn 0 -rotation 0 -scale $scale -rsp 1 $circleName $s ; $name = "pipe"; $ok = 0; $cnt = 1; while ($ok==0){ if (`objExists $name`){ $name = ("pipe"+$cnt); $cnt++; }else { $ok = 1; } } rename $name; } } global proc generatePipe(){ float $radius, $scale ; if (`control -exists radius`){ $radius = `floatSliderGrp -q -v radius`; } if (`control -exists scale`){ $scale = `floatSliderGrp -q -v scale`; } genPipe $radius $scale; } global proc pipeWindow(){ if (`window -exists pipewindow`) {deleteUI -window pipewindow;} window -rtf on -t "Pipe Generator" -sizeable on pipewindow; columnLayout; text -label " Pipe Generator v1.0 - ©2005 Xaebhal" -fn "plainLabelFont"; text -label " xaebhal@hotmail.com" -fn "plainLabelFont"; //Pipe settings separator -style "none" -h 10; separator -style "in" -h 15 -w 300; floatSliderGrp -min 0.01 -max 10 -fmx 1000 -fmn 0.01 -v 1 -f on -l "Radius" -columnWidth3 80 50 110 radius; floatSliderGrp -min 0 -max 10 -fmx 1000 -fmn -1000 -v 1 -f on -l "Scale" -columnWidth3 80 50 110 scale; separator -style "none" -h 10; separator -style "in" -h 15 -w 300; rowLayout -numberOfColumns 2 -columnAttach2 "both" "both" -columnAlign2 "center" "center" -columnWidth2 150 150 buttons; button -label "Create Pipe" -command "generatePipe();" ; button -label "Close Window" -command "deleteUI -window pipewindow" ; showWindow pipewindow; } global proc pipe(){ pipeWindow; }