// ========================================================================== // http://www.tjgalda.com // // Copyright (C) 2007 TJ Galda. All rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to TJ Galda which is protected by U.S. and // Canadian federal copyright law and by international treaties. // // The Data is provided for use exclusively by You. You have the right // to use, modify, and incorporate this Data into other products for // purposes authorized by TJ Galda, without fee. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the // following disclaimer, must be included in all copies of the // Software, in whole or in part, and all derivative works of // the Software, unless such copies or derivative works are solely // in the form of machine-executable object code generated by a // source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // TJ GALDA DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR // PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR // TRADE PRACTICE. IN NO EVENT WILL TJ GALDA AND/OR ITS LICENSORS // BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF TJ GALDA // AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY // OR PROBABILITY OF SUCH DAMAGES. // // http://www.tjgalda.com // ========================================================================== // // TJ Galda Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: tj, june 6, 2007 // // Procedure Name: // tj_createToggleHotkeys.mel // // Description: // This will create a series of toggle hotkeys saved into the // user hotkey section. The user must then go in to the hotkey // editor and assign the keys as they like. // // There is also a default mapping for the hotkeys that one is // able to use, but will overwrite any previously set hotkeys. // // Re-writing the exact calls that the hotkey editor can perform // such as querying if the key is valid, showing what is currently // assigned, and custom mapping the commands is beyond the scope of // this script. It seems foolish to re-write most of the editor // when it is just as easy to use the editor. // // The hotkey editor is called up by default if the user does not assign // the keys, and is automatically forced to show the right category // where the new commands will exist. Part of the hotkey editor script // is appended into this in order to avoid sourcing the entire thing. I // did take the liberty of hacking it down quite a bit. // // Input Arguments: // None // // Return Value: // None. // // http://www.tjgalda.com // ========================================================================== global proc tj_createToggleHotkeys() { //create a window to hold the information // ////////////////// // start window ////////////////// string $tj_cth_winName = "tj_cthWin"; if ( `window -exists $tj_cth_winName` ) deleteUI -window $tj_cth_winName; //catch window name and save into variable string $temp = `window -widthHeight 496 430 -title "TJ_Create Toggle Hotkeys" -in "TJ_Create Toggle Hotkeys" -rtf true -mxb false -s true $tj_cth_winName`; $tj_cth_winName = $temp; columnLayout; text -l ""; text -fn "boldLabelFont" -l " Please select from the following for which hotkeys to create: "; text -l ""; rowColumnLayout -numberOfColumns 3 -columnAttach 1 "right" 0 -columnWidth 1 70 -columnWidth 2 230 -columnWidth 3 150; string $tj_cth_TogAllOnCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllOnCBox`; text -l "Toggle All On"; text -l "[Default Key = CTRL 1 ]"; string $tj_cth_TogAllOffCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllOffCBox`; text -l "Toggle All Off"; text -l "[Default Key = CTRL 2 ]"; string $tj_cth_TogAllNurbsCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllNurbsCBox`; text -l "Toggle All Nurbs"; text -l "[Default Key = CTRL 3 ]"; string $tj_cth_TogAllPolysCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllPolysCBox`; text -l "Toggle All Polys"; text -l "[Default Key = CTRL 4 ]"; string $tj_cth_TogAllCamerasCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllCamerasCBox`; text -l "Toggle All Cameras"; text -l "[Default Key = CTRL 5 ]"; string $tj_cth_TogAllCurvesCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllCurvesCBox`; text -l "Toggle All Curves"; text -l "[Default Key = CTRL 6 ]"; string $tj_cth_TogAllJointsCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllJointsCBox`; text -l "Toggle All Joints"; text -l "[Default Key = CTRL 7 ]"; string $tj_cth_TogAllMiscCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllMiscCBox`; text -l "Toggle All Misc"; text -l "[Default Key = CTRL 8 ]"; string $tj_cth_TogAllWireframeOnShadedCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllWireframeOnShadedCBox`; text -l "Toggle Display Mode of Wireframe On Shaded"; text -l "[Default Key = CTRL 9 ]"; string $tj_cth_TogAllWireframeOverrideCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllWireframeOverrideCBox`; text -l "Toggle Current Object's Wireframe Override"; text -l "[Default Key = CTRL 0 ]"; string $tj_cth_TogAllXrayCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllXrayCBox`; text -l "Toggle Display Mode of Xray"; text -l "[Default Key = CTRL - ]"; string $tj_cth_TogFloatingWinCBox = `checkBox -label "-=>" -v 1 tj_cth_TogFloatingWinCBox`; text -l "(Toggle)Floating Window"; text -l "[Default Key = CTRL = ]"; string $tj_cth_TogIsolSelCBox = `checkBox -label "-=>" -v 1 tj_cth_TogIsolSelCBox`; text -l "Toggle Isolate Selected"; text -l "[Default Key = i ]"; //capture in array all the names string $tj_cth_allToggleBoxes[] = {$tj_cth_TogAllOnCBox, $tj_cth_TogAllOffCBox, $tj_cth_TogAllNurbsCBox, $tj_cth_TogAllPolysCBox, $tj_cth_TogAllCamerasCBox, $tj_cth_TogAllCurvesCBox, $tj_cth_TogAllJointsCBox, $tj_cth_TogAllMiscCBox, $tj_cth_TogAllWireframeOnShadedCBox, $tj_cth_TogAllWireframeOverrideCBox, $tj_cth_TogAllXrayCBox, $tj_cth_TogFloatingWinCBox, $tj_cth_TogIsolSelCBox}; text -l ""; text -l ""; text -l ""; string $tj_cth_TogAllTogsCBox = `checkBox -label "-=>" -v 1 tj_cth_TogAllTogsCBox`; text -fn "boldLabelFont" -l "Toggle All of Above Choices On or Off"; string $tj_cth_boxString = $tj_cth_allToggleBoxes[0]; for ($i = 1; $i < `size($tj_cth_allToggleBoxes)`; $i ++) { $tj_cth_boxString = $tj_cth_boxString+"="+$tj_cth_allToggleBoxes[$i]; } checkBox -e -cc ("tj_cth_togCBox \"tj_cth_TogAllTogsCBox\" \""+$tj_cth_boxString+"\"") $tj_cth_TogAllTogsCBox; text -l ""; text -l ""; setParent ..; //new layout for buttons rowColumnLayout -numberOfColumns 2 -columnAttach 1 "right" 0 -columnWidth 1 20 -columnWidth 2 450 ; text -l ""; button -l " Create the Selected Commands and Open the Hotkey Editor For Custom Mapping" -h 40 -bgc 0.2 0.9 0.6 -ann "This choice will create the commands as user commands, and open the hotkey editor allowing you to choose your keys" -c ("tj_cth_goMethod \"0\" \""+$tj_cth_winName+"\" \""+$tj_cth_boxString+"\""); text -l ""; text -l ""; text -l ""; button -l " Create the Selected Commands Using Default Mapping" -h 40 -bgc 0.3 0.5 1 -ann "This choice will automatically bind the chosen toggles to the default keys, being Ctrl 1-0, Ctrl - and Ctrl +" -c ("tj_cth_goMethod \"1\" \""+$tj_cth_winName+"\" \""+$tj_cth_boxString+"\""); setParent ..; text -l (" "+ " created by TJ Galda" ); setParent ..; // ////////////////// // show window and end ////////////////// showWindow; } //''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' //quick proc to toggle the states of the boxes // global proc tj_cth_togCBox(string $tj_cth_TogAllTogsCBox, string $tj_cth_allTogglesString) { //pass array as large string, need to section up again into array string $tj_cth_allToggles[]; int $numTokens = `tokenize $tj_cth_allTogglesString "=" $tj_cth_allToggles`; int $tj_cth_curState = `checkBox -q -v $tj_cth_TogAllTogsCBox`; for ($tj_cth_cBox in $tj_cth_allToggles) { //force twice to ensure redraw happens. Gotta love Mel. checkBox -e -v $tj_cth_curState $tj_cth_cBox; checkBox -e -v $tj_cth_curState $tj_cth_cBox; } } //''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' // proc to do the command generation, and hotkey binding //accepts flag for default Mapping. // 0 = custom Map, open hotkey editor // 1 = use default mapping, automatically assign keys global proc tj_cth_goMethod(int $tj_cth_defaultMapFlag, string $tj_cth_winName, string $tj_cth_allTogglesString) { // Default Map: // Ctrl + 1 = Tog On // Ctrl + 2 = Tog Off // Ctrl + 3 = Tog Nurbs // Ctrl + 4 = Tog Poly // Ctrl + 5 = Tog Cameras // Ctrl + 6 = Tog Curves // Ctrl + 7 = Tog Joints // Ctrl + 8 = Tog Misc // Ctrl + 9 = Tog Wire on Shade // Ctrl + 0 = Tog Wire Override // Ctrl + - = Tog Xray // Ctrl + = = Tog Floating Win // i = Tog Isolate Select //pass array as large string, need to section up again into array string $tj_cth_allToggles[]; int $numTokens = `tokenize $tj_cth_allTogglesString "=" $tj_cth_allToggles`; int $tj_cth_boxState[]; //line up array of states for ($i = 0; $i < `size($tj_cth_allToggles)`; $i++) { $tj_cth_boxState[$i] = `checkBox -q -v $tj_cth_allToggles[$i]`; } //to save the hotkeys, we need to do 3 things // 1) make a runTimeCommand // 2) make a nameCommand tied to the new runTimeCommand // 3) bind a hotkey to the nameCommand //create array for runTimes Annotation string $tj_cth_runTimeAnnotations[] = {"Toggle everything in the display to being on", "Toggle everything in the display to being off", "Toggle All of your Nurbs Surfaces in the display to being either on or off", "Toggle All of your Polys Surfaces in the display to being either on or off", "Toggle All of your Cameras Surfaces in the display to being either on or off", "Toggle All of your Joints Surfaces in the display to being either on or off", "Toggle All of your Misc Surfaces in the display to being either on or off", "Toggle All of your objects to have wireframe on shaded in the display to being either on or off", "Toggle the current selected object to have wireframe always on in the display to being either on or off", "Toggle on or off Xray mode", "Create a floating window and subsequent uses toggle it's state to either minimized or maximized", "Toggle isolate select mode, displaying only what is selected, on or off"}; //create strings for commands string $tj_cth_togAllOn = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles all on, paste in as a user hotkey"+ "\n////all on"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n {"+ "\n modelEditor -e -allObjects 1 $currentPanel;"+ "\n }"); string $tj_cth_togAllOff = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles all off, paste in as a user hotkey"+ "\n////all off"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n {"+ "\n modelEditor -e -allObjects 0 $currentPanel;"+ "\n }"); string $tj_cth_togNurbs = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of Nurbs surfaces, paste in as a user hotkey"+ "\n////nurbs surfaces"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -nurbsSurfaces $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -nurbsSurfaces 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -nurbsSurfaces 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togPolys = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of Polys, paste in as a user hotkey"+ "\n////polys"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -polymeshes $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -polymeshes 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -polymeshes 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togCams = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of Cameras, paste in as a user hotkey"+ "\n////cameras"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -cameras $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -cameras 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -cameras 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togCrvs = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of Nurbs curves, paste in as a user hotkey"+ "\n////nurbs curves"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -nurbsCurves $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -nurbsCurves 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -nurbsCurves 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togJoints = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of joints, paste in as a user hotkey"+ "\n////joints"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -joints $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -joints 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -joints 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togMisc = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of misc Items, paste in as a user hotkey"+ "\n//"+ "\n//toggle handles and misc, based on locator status"+ "\n//locators"+ "\n//ikHandles"+ "\n//handles"+ "\n//dimensions"+ "\n//pivots"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n {"+ "\n int $on_flag = `modelEditor -q -locators $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -locators 1 $currentPanel;"+ "\n modelEditor -e -ikHandles 1 $currentPanel;"+ "\n modelEditor -e -handles 1 $currentPanel;"+ "\n modelEditor -e -dimensions 1 $currentPanel;"+ "\n modelEditor -e -pivots 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -locators 0 $currentPanel;"+ "\n modelEditor -e -ikHandles 0 $currentPanel;"+ "\n modelEditor -e -handles 0 $currentPanel;"+ "\n modelEditor -e -dimensions 0 $currentPanel;"+ "\n modelEditor -e -pivots 0 $currentPanel;"+ "\n }"+ "\n }"); string $tj_cth_togWOS = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of wireframe on shaded, paste in as a user hotkey"+ "\n////wireframe on shaded"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -wos $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -wos 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -wos 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togWOvr = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of wireframe override on selected item, paste in as a user hotkey"+ "\n////wireframe override"+ "\nstring $wireframer[] = `ls -sl -l`;"+ "\nfor ($thingery in $wireframer)"+ "\n{"+ "\n string $shapes[] = `listRelatives -s $thingery`;"+ "\n for ($shape in $shapes)"+ "\n {"+ "\n int $os_flag = `getAttr ($shape+\".overrideShading\")`;"+ "\n if ($os_flag == 0)"+ "\n {"+ "\n setAttr ($shape+\".overrideEnabled\") 1;"+ "\n setAttr ($shape+\".overrideShading\") 1;"+ "\n }"+ "\n else"+ "\n {"+ "\n setAttr ($shape+\".overrideEnabled\") 1;"+ "\n setAttr ($shape+\".overrideShading\") 0;"+ "\n }"+ "\n }"+ "\n}"); string $tj_cth_togXray = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles visibility of xray, paste in as a user hotkey"+ "\n////xray"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `modelEditor -q -xray $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n modelEditor -e -xray 1 $currentPanel;"+ "\n }"+ "\n else"+ "\n {"+ "\n modelEditor -e -xray 0 $currentPanel;"+ "\n }"+ "\n}"); string $tj_cth_togFWin = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//creates a tj_window, paste in as a user hotkey"+ "\n// after window is created, runs as a toggle in min/maximizing window"+ "\n//"+ "\n// floating window"+ "\nstring $tj_winName = \"tj_window\";"+ "\nif ( `window -exists $tj_winName` )"+ "\n {"+ "\n int $tj_win_vis = `window -q -h $tj_winName`;"+ "\n if ($tj_win_vis > 50)"+ "\n {"+ "\n window -e -wh 1 1 $tj_winName;"+ "\n }"+ "\n else if ($tj_win_vis < 50)"+ "\n {"+ "\n window -e -wh 1200 900 $tj_winName;"+ "\n }"+ "\n }"+ "\nelse"+ "\n {"+ "\n string $tj_window = `window -widthHeight 1000 500 -title \"TJ's Floating Window\""+ "\n $tj_winName`;"+ "\n paneLayout;"+ "\n modelPanel;"+ "\n setParent ..;"+ "\n showWindow $tj_window;"+ "\n window -e -wh 1000 600 $tj_window;"+ "\n }"); string $tj_cth_togIsoS = ("//Super basic script but sharing some useful hotkeys by request"+ "\n//"+ "\n// tj, may 31, 2007"+ "\n//"+ "\n//toggles isolate selected, paste in as a user hotkey"+ "\n////isolate selected"+ "\n$currentPanel = `getPanel -withFocus`;"+ "\nstring $panelType = `getPanel -to $currentPanel`;"+ "\nif ($panelType == \"modelPanel\")"+ "\n{"+ "\nint $on_flag = `isolateSelect -q -s $currentPanel`;"+ "\n if ($on_flag == 0)"+ "\n {"+ "\n enableIsolateSelect $currentPanel true;"+ "\n }"+ "\n else"+ "\n {"+ "\n enableIsolateSelect $currentPanel false;"+ "\n }"+ "\n}"); //strings done //create array for runTimes Commands string $tj_cth_runTimeCommands[] = {$tj_cth_togAllOn, $tj_cth_togAllOff, $tj_cth_togNurbs, $tj_cth_togPolys, $tj_cth_togCams, $tj_cth_togCrvs, $tj_cth_togJoints, $tj_cth_togMisc, $tj_cth_togWOS, $tj_cth_togWOvr, $tj_cth_togXray, $tj_cth_togFWin, $tj_cth_togIsoS}; //create array for nameCommand Annotation string $tj_cth_nameCommandAnnotations[] = {"tj_toggleAllOnNameCommand", "tj_toggleAllOffNameCommand", "tj_toggleAllNurbsNameCommand", "tj_toggleAllPolysNameCommand", "tj_toggleAllCamerasNameCommand", "tj_toggleAllCurvesNameCommand", "tj_toggleAllJointsNameCommand", "tj_toggleAllMiscNameCommand", "tj_toggleWireFrame_on_ShadedNameCommand", "tj_toggleWireframe_OverrideNameCommand", "tj_toggleXrayNameCommand", "tj_floatingWindowNameCommand", "tj_isolateSelectedNameCommand"}; //create array for nameCommand commands string $tj_cth_nameCommands[] = {"tj_toggleAllOn", "tj_toggleAllOff", "tj_toggleAllNurbs", "tj_toggleAllPolys", "tj_toggleAllCameras", "tj_toggleAllCurves", "tj_toggleAllJoints", "tj_toggleAllMisc", "tj_toggleWireFrame_on_Shaded", "tj_toggleWireframe_Override", "tj_toggleXray", "tj_floatingWindow", "tj_isolateSelected"}; //create all runtime and nameCommands as user commands, if selected for ($i = 0; $i < `size($tj_cth_allToggles)`; $i++) { if ($tj_cth_boxState[$i] == 1) { //check if exists and edit for new contents if it does if (`runTimeCommand -q -ex $tj_cth_nameCommands[$i]` == 0) { runTimeCommand -annotation $tj_cth_runTimeAnnotations[$i] -category "User" -command $tj_cth_runTimeCommands[$i] $tj_cth_nameCommands[$i]; } else { runTimeCommand -e -annotation $tj_cth_runTimeAnnotations[$i] -category "User" -command $tj_cth_runTimeCommands[$i] $tj_cth_nameCommands[$i]; warning ("Command "+$tj_cth_nameCommands[$i]+" already existed, editing for new contents..."); } nameCommand -annotation $tj_cth_nameCommandAnnotations[$i] -command $tj_cth_nameCommands[$i] $tj_cth_nameCommandAnnotations[$i]; } } // //commands created //------------------------------------------------------------------- //now either make hotkeys or open the hotkey editor //if chosen, map the keys if ($tj_cth_defaultMapFlag == 1) { // Default Map: // Ctrl + 1 = Tog On // Ctrl + 2 = Tog Off // Ctrl + 3 = Tog Nurbs // Ctrl + 4 = Tog Poly // Ctrl + 5 = Tog Cameras // Ctrl + 6 = Tog Curves // Ctrl + 7 = Tog Joints // Ctrl + 8 = Tog Misc // Ctrl + 9 = Tog Wire on Shade // Ctrl + 0 = Tog Wire Override // Ctrl + - = Tog Xray // Ctrl + = = Tog Floating Win // i = Tog Isolate Select // hotkey -keyShortcut "T" -ctl -alt -name ("tj_copy_trans4NameCommand"); int $j = 0; for ($i = 0; $i < 9; $i++) { if ($tj_cth_boxState[$i] == 1) { //offset hotkey shortcut for array starting at 0 $j = $i + 1; hotkey -keyShortcut $j -ctl -name $tj_cth_nameCommandAnnotations[$i]; } } //finish off the checks and assignments if ($tj_cth_boxState[9] == 1) { hotkey -keyShortcut "0" -ctl -name $tj_cth_nameCommandAnnotations[9]; } if ($tj_cth_boxState[10] == 1) { hotkey -keyShortcut "dash" -ctl -name $tj_cth_nameCommandAnnotations[10]; } if ($tj_cth_boxState[11] == 1) { hotkey -keyShortcut "=" -ctl -name $tj_cth_nameCommandAnnotations[11]; } if ($tj_cth_boxState[12] == 1) { hotkey -keyShortcut "i" -name $tj_cth_nameCommandAnnotations[12]; } //save off the preferences savePrefs; } //------------------------------------------------------------------- //default mapping not chosen, load hotkey editor to show user the new commands else { /////////////// // load up the hotkey editor, and force the user section to come up // as selected. The toggle keys will reside here. hotkeyEditor; //list all the controls from all the UI's // isn't mel elegant? ;) string $tj_allControls[] = `lsUI -ctl`; string $tj_hotkeyScroll = "HotkeyEditorCategoryTextScrollList"; int $tj_foundHotkeyScroll = 0; //check each one for the hotkey editor list we want for ($testItem in $tj_allControls) { if ($testItem == $tj_hotkeyScroll) { $tj_foundHotkeyScroll = 1; } } //if we found the control, select the user field if ($tj_foundHotkeyScroll == 1) { textScrollList -edit -selectItem "User" $tj_hotkeyScroll; //utilize hotkeyEditor script and force it to update //////////////////////////////////////////////////////////////////////// // /// The following is from the hotkeyEditor.mel script that ships with Maya //force this into memory without sourcing the entire hotkey editor script // string $list = "HotkeyEditorCommandTextScrollList"; string $selectedCategory[], $category, $runTimeCommands[]; int $index, $numberOfItems, $numberOfLines, $showItem; waitCursor -state on; $selectedCategory = `textScrollList -q -selectItem HotkeyEditorCategoryTextScrollList`; if (1 == size($selectedCategory)) { if ("Uncategorized" == $selectedCategory[0]) { $selectedCategory[0] = ""; } if (0 < `textScrollList -q -numberOfItems $list`) { textScrollList -e -removeAll $list; } $runTimeCommands = `runTimeCommand -q -commandArray`; for ($index = 0; $index < size($runTimeCommands); $index++) { $category = `runTimeCommand -q -category $runTimeCommands[$index]`; if ($selectedCategory[0] == $category) { textScrollList -e -append $runTimeCommands[$index] $list; } } } if (0 < `textScrollList -q -numberOfItems $list`) { textScrollList -edit -selectIndexedItem 1 $list; } waitCursor -state off; // // end of hotkey editor source //////////////////////////////////////////////////// } //end of check for hotkey editor and updated if present. } //hotkey editor is up, let's close our window if ( `window -exists $tj_cth_winName` ) deleteUI -window $tj_cth_winName; } //end