// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Creation Date: 23 April 2015 // // Procedure Name: // performBakeCustomToolPivot // // Description: // Bakes custom pivot into transform/geometry center // // Input Arguments: // $option : Whether to set the options to default values. // // Return Value: // command string iff $option==2 // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists bakeCustomPivotOrientation`) { optionVar -intValue bakeCustomPivotOrientation 1; } if ($forceFactorySettings || !`optionVar -exists bakeCustomPivotPosition`) { optionVar -intValue bakeCustomPivotPosition 1; } } global proc performBakeCustomToolPivotSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $ori = `optionVar -q bakeCustomPivotOrientation`; int $pos = `optionVar -q bakeCustomPivotPosition`; radioButtonGrp -e -select ($ori && $pos ? /*pos+ori*/3 : $pos ? /*pos only*/1 : /*ori only*/2) bakeCustomToolPivotOption; } global proc performBakeCustomToolPivotCallback(string $parent, int $doIt) { setParent $parent; int $selected = `radioButtonGrp -q -select bakeCustomToolPivotOption`; int $ori = ($selected != /*pos only*/1); int $pos = ($selected != /*ori only*/2); optionVar -intValue bakeCustomPivotPosition $pos; optionVar -intValue bakeCustomPivotOrientation $ori; if ($doIt) { performBakeCustomToolPivot 0; addToRecentCommandQueue "performBakeCustomToolPivot 0" "BakeCustomPivot"; } } proc bakeCustomToolPivotOptions() { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; // Form layout string $parent = `formLayout bakeCustomToolPivotSettings`; string $commandName = "performBakeCustomToolPivot"; string $callback = ($commandName + "Callback " + $parent + " "); string $setup = ($commandName + "Setup " + $parent + " "); setOptionBoxCommandName($commandName); // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performBakeCustomToolPivot.kSettingsFrame"))`; columnLayout; radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_performBakeCustomToolPivot.kBakePivotLabel")) -labelArray3 (uiRes("m_performBakeCustomToolPivot.kBakePositionOption")) (uiRes("m_performBakeCustomToolPivot.kBakeOrientationOption")) (uiRes("m_performBakeCustomToolPivot.kBakePositionAndOrientationOption")) -select 2 -vertical bakeCustomToolPivotOption; setParent ..; // columnLayout setParent $parent; // frameLayout setParent ..; // formLayout // Attach Description/Settings frames to form layout formLayout -e -af $settingsFrame "top" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "left" $gOptionBoxTemplateFrameSpacing -af $settingsFrame "right" $gOptionBoxTemplateFrameSpacing -an $settingsFrame "bottom" $parent; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performBakeCustomToolPivot.kBakePivotButton")) -command ($callback + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + 1) $resetBtn; setOptionBoxTitle((uiRes("m_performBakeCustomToolPivot.kBakePivotOptions"))); // Customize the 'Help' menu item text. setOptionBoxHelpTag("BakePivot"); eval (($setup + 0)); showOptionBox(); } proc bakeCustomToolPivotExecute() { setOptionVars(0); int $ori = `optionVar -q bakeCustomPivotOrientation`; int $pos = `optionVar -q bakeCustomPivotPosition`; bakeCustomToolPivot $pos $ori; } global proc string performBakeCustomToolPivot(int $option) { string $cmd = ""; switch ($option) { case 0: bakeCustomToolPivotExecute; break; case 1: bakeCustomToolPivotOptions; break; default: $cmd = ("performBakeCustomToolPivot 0"); break; } return $cmd; }