// =========================================================================== // 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: 4 April 1997 // // Procedure Name: // performPolyAverageVertex // // Description: // // // Input Arguments: // $option : Whether to set the options to default values. // Return Value: // command string iff $option==2 // // // Initialize optionVars for polyAverageVertex: // Color, Texture, Vertex // proc setIntOptionVars ( string $prefix, int $forceFactorySettings, string $vars[] ) { string $varName; // Must match $vars int $intValues[]={10}; for ( $i = size($vars) ; $i-- ; ) { $varName = ($prefix + $vars[$i]); if ($forceFactorySettings || !`optionVar -exists $varName`) optionVar -intValue $varName $intValues[$i]; } } global proc performPolyAverageVertexSetup (string $parent, int $forceFactorySettings) { string $prefix = "polyAverageVertex"; string $intVars[] = {"i"}; setIntOptionVars($prefix, $forceFactorySettings, $intVars); setParent $parent; for ( $i = size($intVars) ; $i-- ; ) { string $varName = ($prefix + $intVars[$i]); intSliderGrp -edit -value `optionVar -query $varName` $varName; } } global proc performPolyAverageVertexCallback (string $parent, int $doIt) { string $prefix = "polyAverageVertex"; string $intVars[] = {"i"}; setParent $parent; for ( $i = size($intVars) ; $i-- ; ) { string $varName = ($prefix + $intVars[$i]); optionVar -intValue $varName `intSliderGrp -query -value $varName`; } if ($doIt) { performPolyAverageVertex 0; addToRecentCommandQueue "performPolyAverageVertex 0" "PolyAverageVertex"; } } proc polyAverageVertexOptions (string $prefix, string $intVars[]) { // Global template variables for form spacing global int $gOptionBoxTemplateDescriptionMarginWidth; global int $gOptionBoxTemplateFrameSpacing; string $commandName = "performPolyAverageVertex"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; string $varName = ($prefix + $intVars[0]); // Form layout string $parent = `formLayout polyChamferVertexOptions`; // Description frame string $descriptionFrame = `frameLayout -label (uiRes("m_performPolyAverageVertex.kDescriptionFrame")) -mw $gOptionBoxTemplateDescriptionMarginWidth`; columnLayout; text (uiRes("m_performPolyAverageVertex.kDescription1")); text (uiRes("m_performPolyAverageVertex.kDescription2")); setParent $parent; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performPolyAverageVertex.kSettingsFrame"))`; intSliderGrp -label (uiRes("m_performPolyAverageVertex.kSmoothingAmount")) -minValue 1 -maxValue 50 $varName; setParent $parent; setParent ..; // Attach Description/Settings frames to form layout formLayout -e -af $descriptionFrame "top" $gOptionBoxTemplateFrameSpacing -af $descriptionFrame "left" $gOptionBoxTemplateFrameSpacing -af $descriptionFrame "right" $gOptionBoxTemplateFrameSpacing -an $descriptionFrame "bottom" -ac $settingsFrame "top" $gOptionBoxTemplateFrameSpacing $descriptionFrame -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_performPolyAverageVertex.kAverageButton")) -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_performPolyAverageVertex.kAverageVerticesOptions")) ); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "AverageVertices" ); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } global proc string performPolyAverageVertex (int $option) { string $prefix = "polyAverageVertex"; string $intVars[] = {"i"}; string $cmd=""; switch ($option) { case 0: setIntOptionVars($prefix, false, $intVars); $cmd = $prefix; for ( $i = size($intVars) ; $i-- ; ) { string $varName = ($prefix + $intVars[$i]); int $ival = `optionVar -query $varName`; $cmd = $cmd + " -" + $intVars[$i] + " " + $ival; } polyPerformAction $cmd "v" 0; // make sure node is selected when there is history if ( 0 != size(`ls -sl`) || (0 != size(`ls -hl`)) ) { string $tmp[] = `listHistory`; string $totalSel[]; for ($opNode in $tmp) { if (`nodeType $opNode` == "polyAverageVertex") { $totalSel[size($totalSel)] = $opNode; } } if (size($totalSel) > 0) select -add $totalSel[0]; } setToolTo ShowManips; break; case 1: polyAverageVertexOptions($prefix, $intVars); break; case 2: $cmd="performPolyAverageVertex 0"; break; } return $cmd; }