/* There is a major error right now, but it only happens after extended use of this tool. Should the curve editor stop acting how it should, go to file>Reset. This will completely wipe any and all prefs and saves of the tool and it SHOULD fix the error. Otherwise Restart Maya and do optionVar -rm "sgkCurvesExtrudeTaperOptionVar"; in mel line. Still alot of errors with that stupid gradient control. I don't get how maya can use it with minimal bugs and we get a crappy version. I had to come up with so many ways to make sure I am getting accurate values... If ANY values. */ global proc sgkVinesToolset() { int $pomLoaded = `pluginInfo -query -l nearestPointOnMesh`; if( !$pomLoaded ){ loadPlugin nearestPointOnMesh; } int $comLoaded = `pluginInfo -query -l closestPointOnCurve`; if( !$comLoaded ){ loadPlugin closestPointOnCurve; } string $window = "sgkVinesToolset";//Global name for window if (`window -exists $window`)//Is my window there? deleteUI $window; window -title "Klockworks Particle Vines Toolset" -widthHeight 522 300 -maximizeButton false $window; menuBarLayout; menu -label "File"; menuItem -label "Reset" -command "sgkVinesToolsetReset"; menuItem -label "Auto-Find" -checkBox 1 autoFind; scrollLayout; columnLayout -columnAlign "left"; separator -style "none" -height 10; frameLayout -collapsable 1 -label "Particles" -width 484 -height 164 -borderStyle "etchedIn" particlesAndEmitter; columnLayout; separator -style none -width 480; intSliderGrp -field 1 -label "Max Count" -fieldMinValue -1 -fieldMaxValue 100 -value -1 -minValue -1 -maxValue 40 maxCount; checkBox -label "Lifespan" -align "left" -value 0 -changeCommand "sgkLifespanToggle" lifespan; floatSliderGrp -field 1 -precision 3 -label "Lifespan" -fieldMinValue 0 -fieldMaxValue 100 -minValue 0 -maxValue 10 -enable 0 lifespanValue; floatSliderGrp -field 1 -precision 3 -label "Lifespan Random" -fieldMinValue 0 -fieldMaxValue 100 -minValue 0 -maxValue 10 -enable 0 lifespanValueRandom; floatSliderGrp -field 1 -precision 0 -label "Seed" -fieldMinValue 0 -fieldMaxValue 100 -minValue 0 -maxValue 10 -enable 0 lifespanValueSeed; rowLayout -numberOfColumns 3 -columnWidth3 220 80 180; checkBox -label "Auto Collide Particles to Shape" -align "left" -value 1 autoCollide; button -label "Make Emitter" -align "center" -command "sgkMakeEmitter"; button -label "Make Crawl over Surface" -align "center" -command "sgkMakeCollide"; setParent ..; setParent ..; setParent ..; frameLayout -collapsable 1 -label "Fields and Goals" -width 484 -height 51 -borderStyle "etchedIn" fieldAndGoal; columnLayout; separator -style none -width 480; rowLayout -numberOfColumns 4 -columnWidth4 50 68 43 32; button -label "Gravity" -align "center" -command "sgkGravFieldMaker"; button -label "Turbulance" -align "center" -command "sgkTurbFieldMaker"; button -label "Vortex" -align "center" -command "sgkVortexFieldMaker"; button -label "Goal" -align "center" -command "sgkGoalMaker"; //button -label "Finish Line" -align "center" -command "sgkFinishLine"; setParent ..;//column setParent ..;//frame setParent ..;//column frameLayout -collapsable 1 -label "Particle trail Curves" -width 484 -height 143 -borderStyle "etchedIn" particleToCurve; columnLayout; separator -style none -width 480; floatFieldGrp -numberOfFields 1 -precision 0 -label "Start Frame" -value1 1 startFrame; floatFieldGrp -numberOfFields 1 -precision 0 -label "End Frame" -value1 240 endFrame; floatFieldGrp -numberOfFields 1 -precision 0 -label "Curve Degree" -value1 3 curveDegree; floatFieldGrp -numberOfFields 1 -precision 0 -label "Mimimum Degree" -value1 3 minCurveDegree; button -label "Go!" -align "center" -command "sgkPartsToCurves"; setParent ..;//frame setParent ..;//column frameLayout -collapsable 1 -label "Extrude Curve Tools" -width 484 -height 277 -borderStyle "etchedIn" extrudeCurveTools; columnLayout; separator -style none -width 480; gradientControlNoAttr -w 420 -h 150 -changeCommand "sgkChangeCurveControl(0)" extrudeCurve; gradientControlNoAttr -e -optionVar "sgkCurvesExtrudeTaperOptionVar" -currentKey 0 extrudeCurve; rowLayout -numberOfColumns 2 -columnWidth2 300 90; floatFieldGrp -numberOfFields 1 -precision 3 -label "Selected Position" -changeCommand "sgkChangeCurveControl(1)" extrudeCurveSelPos; checkBox -label "Special Extrusion" -align "left" -value 1 -changeCommand "sgkSpecialExtrusion" specialExtrusion; setParent ..; floatFieldGrp -numberOfFields 1 -precision 3 -label "Selected Value" -changeCommand "sgkChangeCurveControl(1)" extrudeCurveSelValue; rowLayout -numberOfColumns 2 -columnWidth2 200 160; optionMenu -label "Interpolation" -changeCommand "sgkChangeCurveControl(1)" extrudeCurveInterpolation; menuItem -label "None"; menuItem -label "Linear"; menuItem -label "Smooth"; menuItem -label "Spline"; checkBox -label "Add noise to Extrude" -align "left" -value 1 noiseExtrudeCurve; setParent ..; rowLayout -numberOfColumns 3 -columnWidth3 55 175 160; button -label "Make Extrusions" -command "sgkCurveExtruding"; floatFieldGrp -numberOfFields 1 -precision 5 -label "Initial Radius" -value1 .25 cvRadius; floatFieldGrp -numberOfFields 1 -precision 0 -label "Cvs to rebuild" -value1 150 cvRebuildAmount; setParent ..;//row setParent ..;//column setParent ..;//frame frameLayout -collapsable 1 -label "Finishing Touches" -width 484 -height 277 -borderStyle "etchedIn" animationCurveTools; columnLayout; separator -style none -width 480; button -label "Offset from a Mesh" -align "center" -command "sgkCurveOffsetToMesh()"; button -label "Set Keys!" -align "center" -command "sgkCurveAnimate"; showWindow $window; sgkChangeCurveControl(2); } global proc sgkSpecialExtrusion()//toggle for the gradient controls. Unfortunatly the noAttr control is MISSING an enabled flag, yet the other version has it? The hell? { int $extrudeToggle = `checkBox -q -value specialExtrusion`; switch ($extrudeToggle){ case 1: floatFieldGrp -edit -enable 1 extrudeCurveSelPos; checkBox -edit -enable 1 noiseExtrudeCurve; floatFieldGrp -edit -enable 1 extrudeCurveSelValue; optionMenu -edit -enable 1 extrudeCurveInterpolation; break; case 0: floatFieldGrp -edit -enable 0 extrudeCurveSelPos; checkBox -edit -enable 0 noiseExtrudeCurve; floatFieldGrp -edit -enable 0 extrudeCurveSelValue; optionMenu -edit -enable 0 extrudeCurveInterpolation; break; } } global proc sgkVinesToolsetReset()//Full reset on the GUI. sets up default values. This has to be done the first time the script runs because of the gradient control. { string $window = "sgkVinesToolset"; deleteUI $window; optionVar -rm "sgkCurvesExtrudeTaperOptionVar"; if (`windowPref -exists $window`) windowPref -remove $window; if (!`optionVar -exists "sgkCurvesExtrudeTaperOptionVar"`){ optionVar -stringValueAppend "sgkCurvesExtrudeTaperOptionVar" "0,1,2"; optionVar -stringValueAppend "sgkCurvesExtrudeTaperOptionVar" "1,0,2"; } sgkVinesToolset(); } global proc sgkChangeCurveControl(int $passed)//Getting my gradient control to work like mayas. { float $currentKeyVal = `gradientControlNoAttr -q -currentKeyCurveValue extrudeCurve`; float $currentKeyInterp = `gradientControlNoAttr -q -currentKeyInterpValue extrudeCurve`; int $currentKeyIndex = `gradientControlNoAttr -q -ck extrudeCurve`; float $changedKeyVal = `floatFieldGrp -q -value1 extrudeCurveSelValue`; float $changedKeyInterp = `optionMenu -q -select extrudeCurveInterpolation`; float $changedKeyPos = `floatFieldGrp -q -value1 extrudeCurveSelPos`; int $i, $j; string $asString = `gradientControlNoAttr -q -asString extrudeCurve`; string $optionVar[] = `optionVar -q sgkCurvesExtrudeTaperOptionVar`; string $buffer[]; float $currentKeyPos; //val,pos,interp switch ($passed){ case 1://if the fields are changed this updates the gradient tokenize $asString "," $buffer; //overboard on string control, but it is not my fault maya decided to store FLOAT values in a frickn string. Also there is no direct way to query the position of the gradient control, or even EDIT it. If there was I wouldn't have to do this sillyness. string $bufferCommand = "\""; $buffer[$currentKeyIndex*3] = $changedKeyVal;//val $buffer[$currentKeyIndex*3+2] = $changedKeyInterp - 1;//interp $buffer[$currentKeyIndex*3+1] = $changedKeyPos;//pos for ($i = 0; $i < size($buffer); $i++){ if ($i < size($buffer) - 1) $bufferCommand = ($bufferCommand + $buffer[$i] + ","); else $bufferCommand = ($bufferCommand + $buffer[$i] + "\""); } gradientControlNoAttr -e -asString $bufferCommand extrudeCurve;//ok, so optionVar stores the strings as arrays, kinda. val,pos,interp and then you get a new string for another point. With the control it stores it as one GIANT string, that is retarded. break; case 0://gradient gets changed, updates fields. tokenize $asString "," $buffer; //used for next loops for ($i = 0; $i < size($buffer)/3; $i++){//curve to fields if (floatEq($currentKeyVal, $buffer[$i*3])){ $currentKeyPos = $buffer[$i*3+1]; } } floatFieldGrp -e -value1 $currentKeyVal extrudeCurveSelValue; floatFieldGrp -e -value1 $currentKeyPos extrudeCurveSelPos; optionMenu -e -select ($currentKeyInterp+1) extrudeCurveInterpolation;//why can't programmers decide to start counting at the same place? break; case 2: string $bufferCommand = "\""; int $total = size($optionVar) * 3 - 1; for ($i = 0; $i