// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // performAlignObjects // // Description: // // // Input Arguments: // $option : Whether to set the options to default values. // Return Value: // command string iff $option==2 // // // Initialize optionVars for align: // proc setOptionVars ( string $prefix, int $forceFactorySettings ) { string $varName; string $toggles[] = {"atl", "axisX", "axisY", "axisZ"}; int $defaults[] = {0, 1, 0, 0}; int $i; for ($i = size($defaults) ; $i-- ; ) { $varName = ($prefix + $toggles[$i]); if ($forceFactorySettings || !`optionVar -exists $varName`) optionVar -intValue $varName $defaults[$i]; } $varName = ($prefix + "mode"); if ($forceFactorySettings || !`optionVar -exists $varName`) optionVar -stringValue $varName "Mid"; } global proc updateAlignMode(string $value) { string $prefix = "align"; string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"}; string $varName = $prefix; for ($j= size($strIcons) ; $j-- ; ) { if ($strIcons[$j] == $value) symbolCheckBox -e -v true ($varName+$strIcons[$j]); else symbolCheckBox -e -v false ($varName+$strIcons[$j]); } if (($value == "Dist") || ($value == "Stack")) optionMenuGrp -e -en 0 ($prefix+"atl"); else optionMenuGrp -e -en 1 ($prefix+"atl"); } global proc performAlignObjectsSetup (string $parent, int $forceFactSettings) { string $prefix = "align"; setOptionVars($prefix, $forceFactSettings); setParent $parent; string $varName = ($prefix + "atl"); int $ival = `optionVar -q $varName`; if ($ival) optionMenuGrp -e -select 2 $varName; else optionMenuGrp -e -select 1 $varName; $varName = $prefix + "mode"; updateAlignMode(`optionVar -query $varName`); $varName = $prefix + "axis"; checkBoxGrp -e -v1 `optionVar -query ($varName+"X")` $varName; checkBoxGrp -e -v2 `optionVar -query ($varName+"Y")` $varName; checkBoxGrp -e -v3 `optionVar -query ($varName+"Z")` $varName; } global proc performAlignObjectsCallback (string $parent, int $doIt) { string $prefix = "align"; string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"}; int $i; int $j; setParent $parent; string $varName = $prefix + "atl"; int $ival = `optionMenuGrp -q -select $varName`; if ($ival == 2) optionVar -intValue $varName 1; else optionVar -intValue $varName 0; for ($j= size($strIcons) ; $j-- ; ) if (`symbolCheckBox -q -v ($prefix+$strIcons[$j])`) { optionVar -stringValue ($prefix+"mode") $strIcons[$j]; break; } $varName = $prefix+"axis"; optionVar -intValue ($varName+"X") `checkBoxGrp -q -v1 $varName`; optionVar -intValue ($varName+"Y") `checkBoxGrp -q -v2 $varName`; optionVar -intValue ($varName+"Z") `checkBoxGrp -q -v3 $varName`; if ($doIt) { performAlignObjects 0; addToRecentCommandQueue "performAlignObjects 0" "align"; } } proc AlignObjectsOptions (string $prefix) { string $commandName = "performAlignObjects"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $strIcons[] = {"Min", "Mid", "Max", "Dist", "Stack"}; string $tips[]; $tips[size($tips)] = (uiRes("m_performAlignObjects.kTips1")); $tips[size($tips)] = (uiRes("m_performAlignObjects.kTips2")); $tips[size($tips)] = (uiRes("m_performAlignObjects.kTips3")); $tips[size($tips)] = (uiRes("m_performAlignObjects.kTips4")); $tips[size($tips)] = (uiRes("m_performAlignObjects.kTips5")); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; string $parent = `columnLayout -adjustableColumn 1`; rowColumnLayout -nc (1+size($strIcons)) -cw 1 165 -cw 2 40 -cw 3 40 -cw 4 40 -cw 5 40 -cw 6 40; text -al "right" -label (uiRes("m_performAlignObjects.kAlignMode")) ; for ($j = 0 ; $j < size($strIcons) ; $j++ ) { symbolCheckBox -cc ("updateAlignMode "+$strIcons[$j]) -oni ("alignOn"+$strIcons[$j]+".png") -ofi ("align"+$strIcons[$j]+".png") -annotation $tips[$j] ($prefix+$strIcons[$j]); } text -al "right" -label ""; text -al "center" -label (uiRes("m_performAlignObjects.kMin")); text -al "center" -label (uiRes("m_performAlignObjects.kMid")); text -al "center" -label (uiRes("m_performAlignObjects.kMax")); text -al "center" -label (uiRes("m_performAlignObjects.kDist")); text -al "center" -label (uiRes("m_performAlignObjects.kStack")); setParent ..; separator -h 5 -style "none"; string $worldX = (uiRes("m_performAlignObjects.kWorldX")); string $worldY = (uiRes("m_performAlignObjects.kWorldY")); string $worldZ = (uiRes("m_performAlignObjects.kWorldZ")); checkBoxGrp -numberOfCheckBoxes 3 -label (uiRes("m_performAlignObjects.kAlignIn")) -labelArray3 $worldX $worldY $worldZ ($prefix+"axis"); optionMenuGrp -label (uiRes("m_performAlignObjects.kAlignTo")) ($prefix+"atl"); menuItem -label (uiRes("m_performAlignObjects.kSelectionAverage")) ; menuItem -label (uiRes("m_performAlignObjects.kLastSelectedObject")) ; setParent -m ..; waitCursor -state 0; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performAlignObjects.kAlign")) -command ($callback + " " + $parent + " " + 1) $applyBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; setOptionBoxTitle (uiRes("m_performAlignObjects.kAlignObjectsOptions")); setOptionBoxHelpTag( "AlignObjectsoptions" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } global proc string performAlignObjects (int $option) { string $prefix = "align"; string $cmd=""; switch ($option) { case 0: setOptionVars($prefix, false); $cmd = $prefix; string $varName = ($prefix + "atl"); if (`optionVar -q $varName`) $cmd = $cmd + " -atl"; $varName = ($prefix + "mode"); string $val = `optionVar -query $varName`; $varName = ($prefix + "axisX"); if (`optionVar -query $varName`) $cmd = $cmd + " -x "+ $val; $varName = ($prefix + "axisY"); if (`optionVar -query $varName`) $cmd = $cmd + " -y "+ $val; $varName = ($prefix + "axisZ"); if (`optionVar -query $varName`) $cmd = $cmd + " -z "+ $val; evalEcho($cmd); break; case 1: AlignObjectsOptions($prefix); break; case 2: $cmd="performAlignObjects 0"; break; } return $cmd; }