// llSpiralWindow.MEL // ////////////////////////// // // Maya script file // ////////////////////////// // // Author : Lluís Llobera // (lluisllobera@hotmail.com) // // Creation date : 12/I/2001 // Update 1.5 : 18/VI/2001 // // Main procedure : type "llSpiralWindow" in the Command Line or Script Editor // ////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Spirals are quite a hard thing to do, and they are so very useful! Many people, unaware that // MEL provides a simple way for creating them, usually uses animated sweeps and so on. That's the real thing! // // UPDATE 1.5 : fixed a minor bug, and implemented a new "around NURBS curve" option // // // Enjoy!! // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// // llSWactuatlitzaZones // ////////////////////////////////// // // cada cop que canvia una de les seleccions principals, activa // o desactiva els camps de la finestra // ///////////////////////////////// global proc llSWActualitzaZones () { // comprova primera regió string $NOM = `radioCollection -q -sl OnSpiral` ; if ($NOM == "SpSurf") { textField -e -en 0 NomSuperficie ; radioButton -e -en 0 SpCyl ; radioButton -e -en 0 SpSphere ; radioButton -e -en 0 SpCone ; radioButton -e -en 0 SpTorus ; textField -e -en 0 NomCorba ; floatFieldGrp -e -en 0 RadiEspiral ; } else if ($NOM == "SpName") { textField -e -en 1 NomSuperficie ; radioButton -e -en 0 SpCyl ; radioButton -e -en 0 SpSphere ; radioButton -e -en 0 SpCone ; radioButton -e -en 0 SpTorus ; textField -e -en 0 NomCorba ; floatFieldGrp -e -en 0 RadiEspiral ; } else if ($NOM == "SpShape") { textField -e -en 0 NomSuperficie ; radioButton -e -en 1 SpCyl ; radioButton -e -en 1 SpSphere ; radioButton -e -en 1 SpCone ; radioButton -e -en 1 SpTorus ; textField -e -en 0 NomCorba ; floatFieldGrp -e -en 0 RadiEspiral ; } else if ($NOM == "SpCurve") { textField -e -en 0 NomSuperficie ; radioButton -e -en 0 SpCyl ; radioButton -e -en 0 SpSphere ; radioButton -e -en 0 SpCone ; radioButton -e -en 0 SpTorus ; textField -e -en 1 NomCorba ; floatFieldGrp -e -en 1 RadiEspiral ; } ; } ; // global proc llSWActualitzaZones ////////////////////////////////// // llSpiralWindow // ////////////////////////////////// // // procediment principal -- crea la finestra i crida al procediment de creació // ///////////////////////////////// global proc llSpiralWindow () { if (`window -ex finestraSpiral`== true) deleteUI finestraSpiral ; window -wh 315 525 -title "llSpiralWindow v 1.5" -s 0 finestraSpiral ; columnLayout estrSpiral ; text "\n Spiral v 1.5\n" ; setParent .. ; separator -w 700 -parent estrSpiral ; separator -style "none" -h 10 ; columnLayout -cat "left" 25 llocSpiral ; text "Create Spiral : " ; setParent llocSpiral ; columnLayout -cat "left" 30 llocSpiral2 ; radioCollection -cia OnSpiral ; separator -style "none" -h 10 ; radioButton -sl -label "on selected surface" -cc "llSWActualitzaZones" SpSurf ; separator -style "none" -h 5 ; radioButton -label "on surface named : " -cc "llSWActualitzaZones" SpName ; separator -style "none" -h 5 ; columnLayout -cat "left" 40 nomSuperficie ; textField -w 200 -en 0 NomSuperficie ; setParent llocSpiral2 ; separator -style "none" -h 5 ; radioButton -label "on primitive shape : " -cc "llSWActualitzaZones" SpShape ; radioCollection -cia PrimSpiral ; separator -style "none" -h 10 ; columnLayout -cat "left" 30 PrimSpiralCol ; radioButton -sl -label "cylinder" -en 0 SpCyl ; separator -style "none" -h 5 ; radioButton -label "sphere" -en 0 SpSphere; separator -style "none" -h 5 ; radioButton -label "cone" -en 0 SpCone ; separator -style "none" -h 5 ; radioButton -label "torus" -en 0 SpTorus ; setParent llocSpiral2 ; separator -style "none" -h 5 ; radioButton -cl OnSpiral -label "around NURBS curve : " -cc "llSWActualitzaZones" SpCurve ; separator -style "none" -h 5 ; columnLayout -cat "left" 40 -rs 5 nomCorbaLayout ; textField -p nomCorbaLayout -w 200 -en 0 NomCorba ; floatFieldGrp -p nomCorbaLayout -en 0 -v1 1 -l "Spiral Radius : " -cw 1 80 RadiEspiral ; separator -style "none" -h 5 ; separator -w 700 -p estrSpiral ; columnLayout -p estrSpiral -cat "left" 25 llocSpiral2 ; separator -style "none" -h 10 ; text "Spiral Settings : " ; separator -style "none" -h 5 ; floatFieldGrp -numberOfFields 1 -label "number of rounds : " -value1 10 -pre 0 numVoltes ; setParent llocSpiral2 ; separator -h 5 -style "none" ; columnLayout -cat "left" 38 columnaUV ; text "create along : " ; separator -style "none" -h 5 ; radioCollection -cia coleUV ; rowLayout -nc 2 -columnAttach 1 "left" 45 alongRow ; radioButton "U" ; radioButton -sl "V" ; setParent llocSpiral2 ; separator -h 10 -style "none" ; separator -w 700 -p estrSpiral ; columnLayout -p estrSpiral -cat "left" 100 llocSpiral3 ; separator -h 12 -style "none" ; button -command "llSWspiralGo" -w 100 -label "Go!" botoGo ; separator -h 8 -style "none" ; showWindow finestraSpiral ; window -e -wh 315 525 finestraSpiral ; } ; // global proc llSpiralWindow ////////////////////////////////// // llSWspiralGo // ////////////////////////////////// // // Agafa el nom de la superfície, crea l'espiral i esborra la història // ////////////////////////////////// global proc llSWspiralGo () { string $NOM[] ; int $CREAR = 0 ; global string $ESBORRAR[] ; int $FCORBA = 0 ; string $DIRECCIO ; string $CIRC[] ; // agafar el nom de la superfície -- // si s'ha de fer una primitiva, fer-la string $TIPUS = `radioCollection -q -sl OnSpiral` ; if ($TIPUS == "SpShape") { $CREAR = 1 ; string $TIPUS = `radioCollection -q -sl PrimSpiral` ; if ($TIPUS == "SpCyl") $ESBORRAR = `cylinder -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -hr 2 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 1 -ch 1`; else if ($TIPUS == "SpSphere") $ESBORRAR = `sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1` ; else if ($TIPUS == "SpCone") $ESBORRAR = `cone -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -hr 2 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 1 -ch 1` ; else if ($TIPUS == "SpTorus") $ESBORRAR = `torus -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -msw 360 -r 1 -hr 0.5 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1` ; } ; // SpShape if ($TIPUS == "SpName") select -r `textField -q -text NomSuperficie` ; if ($TIPUS == "SpCurve") { $CREAR = 1 ; $FCORBA = 1 ; $CIRC = eval ("circle -ch 0 -r " + `floatFieldGrp -q -v1 RadiEspiral` ) ; string $CURV = `textField -q -text NomCorba` ; float $COORD[] = `getAttr ($CURV + ".controlPoints[0]")` ; move -r $COORD[0] $COORD[1] $COORD[2] $CIRC[0] ; $ESBORRAR = `extrude -ch 0 -po 0 -et 2 -ucp 1 -fpt 1 -upn 1 -rsp 0 $CIRC[0] $CURV` ; select -r $ESBORRAR[0] ; } ; // SpCorba $NOM = `ls -sl -dag -type "shape"` ; // comprovar superfície if ($FCORBA == 0) { $DIRECCIO = `radioCollection -q -sl coleUV` ; } else $DIRECCIO = "U" ; int $CORRECTE = eval ("getAttr " + $NOM[0] + ".form" + $DIRECCIO) ; if ($CORRECTE == 0) { if (`size $ESBORRAR` > 0) delete $ESBORRAR[0] ; error ("Please specify a surface that is closed or periodic along the " + $DIRECCIO + " direction") ; } else { // variables float $VOLTESU = 1 ; float $VOLTESV = 1 ; if ($DIRECCIO == "U") $VOLTESU = `floatFieldGrp -q -v1 numVoltes` ; else $VOLTESV = `floatFieldGrp -q -v1 numVoltes` ; float $SPANSU[] = eval ("getAttr " + $NOM[0] + ".minMaxRangeU") ; float $SPANSV[] = eval ("getAttr " + $NOM[0] + ".minMaxRangeV") ; // fer espiral string $CORBA_SUP = eval( "curveOnSurface -d 1 -uv " + $SPANSU[0] + " " + $SPANSV[0] + " -uv " + ($SPANSU[1] * $VOLTESU) + " " + ($SPANSV[1] * $VOLTESV) + " " + $NOM[0] ) ; string $CORBA[] = `duplicateCurve -ch 1 -rn 0 -local 0 ($NOM[0] + "->" + $CORBA_SUP) ` ; DeleteHistory ; delete $CORBA_SUP ; rename "spiral1" ; xform -cp ; if ($CREAR == 1) delete $ESBORRAR ; if ($FCORBA == 1) delete $CIRC ; } ; // correcte = 1 } ; // global proc llSWSpiralGo ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // // EoS llSpiralWindow.mel // /////////////////////////////////////////////////////////////////////////////////////////////////////////////