/* '' Author: Jeremiah Grant '' Title: jgFlipBlend.mel '' Date: 04-29-2005 '' '' Description: Flips objects for blendshapes '' '' Instructions: source jgFlipBlend.mel. Select base object and press "Select Base Object" button '' Then select the shape to flip and press "Select Shape to Flip" button. Choose which axis '' to flip the shape on. Press Flip Shape. '' '' Thanks to ideas from forums CGTalk.com and Highend3d.com '' Based off of John Homer's jhMirrorPolyShape script '' '' You can email me at jeremiah@jeremiahgrant.com '' Website: www.jeremiahgrant.com */ // Main UI proc proc jgFlipBlend() { string $obj[]; if (`window -ex jgFlipBlendUI`) deleteUI -wnd jgFlipBlendUI; window -t "jgFlipBlend" -wh 288 148 -rtf 1 -mb 1 jgFlipBlendUI; columnLayout -adj 1; rowColumnLayout -numberOfColumns 2 -columnWidth 1 150 -columnWidth 2 130; string $tf1 = `textField -text "" -w 200 -editable 1 -ip 1 -it $obj[0] -ann "Select Base Object" base`; button -label "Select Base Object" -ann "Select Base Object" -c "$obj = `ls -sl`; textField -e -text $obj[0] base;" loadBaseButton; string $tf2 = `textField -text "" -w 200 -editable 1 -ip 1 -it $obj[0] -ann "Select Shape to Flip" shape`; button -label "Select Shape to Flip" -ann "Select Shape to Flip" -c "$obj = `ls -sl`; textField -e -text $obj[0] shape;" loadShapeButton; setParent..; separator -h 15 -style "none"; string $db = `optionMenu -w 280 -l " Flip Direction " -ann "Choose on which direction the shape should be flipped." dirOption`; menuItem -label "X"; menuItem -label "Y"; menuItem -label "Z"; separator -h 15 -style "none"; button -l "Flip Shape" -c ("jgButAction "+$tf1+" "+$tf2+" "+$db); showWindow; } // Button Action // Accepts 3 UI elements, queries them and sends them to jgBlendMain // Vars: $tf1 = The base blend object UI // $tf2 = The one side shape to flip UI // $db = the direction on which to flip the object UI proc jgButAction(string $tf1, string $tf2, string $db) { string $base = `textField -q -text $tf1`; string $shape = `textField -q -text $tf2`; string $flipDir = `optionMenu -q -v $db`; jgBlendMain $flipDir $base $shape; } // Main proc. This proc has all the power // Accepts 3 Vars // Vars: $flipDir = The direction on which to flip the object // $base = The base blend object // $half1 = The one side shape to flip proc jgBlendMain(string $flipDir, string $base, string $half1) { // Duplicate base // $temp is the wrap influence string $temp[] = `duplicate $base`; // duplicate again to make flipped shape string $half2[] = `duplicate $base`; // Temp blend shape string $blend[] = `blendShape -name "flipBlend" $half1 $temp[0]`; // flip the shape setAttr ($temp[0]+".scale"+$flipDir) -1; // Group and scale to prevent wrap deformer problems string $group = `group $temp[0] $half2[0]`; setAttr ($group+".s") 50 50 50; // Create wrap, apply it, delete history and resize to normal select $half2[0] $temp[0]; string $wrap[] = `doWrapArgList "2" { "1", "0", "1" }`; setAttr ($blend[0] + "." + $half1) 1; DeleteHistory; setAttr ($group+".s") 1 1 1; parent -w $half2[0]; delete $group; } jgFlipBlend;