// =========================================================================== // 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: // performPolyCut // // Description: // // // Input Arguments: // $option : Whether to set the options to default values. // Return Value: // command string iff $option==2 // // // Initialize optionVars for polyCut: // Color, Texture, Vertex // global proc disablePerformPolyCutOffset() { if (`control -ex polyPlaneExtractOffset`) disable polyPlaneExtractOffset; } global proc enablePerformPolyCutOffset() { if (`control -ex polyPlaneExtractOffset`) disable -v false polyPlaneExtractOffset; } global proc updatePerformPolyCutOffset() { if (`checkBoxGrp -query -value1 polyPlaneExtractFaces`) { enablePerformPolyCutOffset; checkBoxGrp -e -value1 off polyPlaneDeleteFaces; } else { disablePerformPolyCutOffset; } } global proc updatePerformPolyCutTRS() { int $val = `radioButtonGrp -query -sl polyPlaneCutDirection`; string $btn; if ($val == 1) { // Interactive Cut. Rename the button labels accordingly.. $btn = getOptionBoxApplyBtn(); if ($btn != "") button -edit -label (uiRes("m_performPolyCut.kUpdateEnterCutTool")) $btn; $btn = getOptionBoxApplyAndCloseBtn(); if ($btn != "") button -edit -label (uiRes("m_performPolyCut.kUpdateEnterCutToolAndClose")) $btn; setOptionBoxTitle( (uiRes("m_performPolyCut.kUpdateCutFacesToolOptions")) ); } else { $btn = getOptionBoxApplyBtn(); if ($btn != "") button -edit -label (uiRes("m_performPolyCut.kApply")) $btn; $btn = getOptionBoxApplyAndCloseBtn(); if ($btn != "") button -edit -label (uiRes("m_performPolyCut.kCut")) $btn; setOptionBoxTitle( (uiRes("m_performPolyCut.kUpdateCutFacesOptions"))); } } proc setOptionVars ( int $forceFactorySettings ) { // -pcx/-planeCenterX -pcy/-planeCenterY -pcz/-planeCenterZ // -rx/-planeRotateX -ry/-planeRotateY -rz/-planeRotateZ // -psu/-planeScaleX -psv/-planeScaleY // -cd/-cuttingDirection if ($forceFactorySettings || !`optionVar -exists "polyPlaneCutDirection"`) { optionVar -intValue "polyPlaneCutDirection" 1; } // -df/-deleteFaces if ($forceFactorySettings || !`optionVar -exists "polyPlaneDeleteFaces"`) { optionVar -intValue "polyPlaneDeleteFaces" 0; } // -ef/-extractFaces if ($forceFactorySettings || !`optionVar -exists "polyPlaneExtractFaces"`) { optionVar -intValue "polyPlaneExtractFaces" 0; } // -eo/-extractOffset if ($forceFactorySettings || !`optionVar -exists "polyPlaneExtractOffset"`) optionVar -floatValue "polyPlaneExtractOffset" 0.5 -floatValueAppend "polyPlaneExtractOffset" 0.5 -floatValueAppend "polyPlaneExtractOffset" 0.5; } global proc performPolyCutSetup (string $parent, int $forceFactorySettings) { string $prefix = "polyCut"; float $vals[], $val; setOptionVars($forceFactorySettings); setParent $parent; int $ival = `optionVar -query "polyPlaneCutDirection"`; radioButtonGrp -edit -sl $ival polyPlaneCutDirection; updatePerformPolyCutTRS; checkBoxGrp -edit -value1 `optionVar -query "polyPlaneDeleteFaces"` polyPlaneDeleteFaces; checkBoxGrp -edit -value1 `optionVar -query "polyPlaneExtractFaces"` polyPlaneExtractFaces; $vals = `optionVar -query "polyPlaneExtractOffset"`; floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] -value3 $vals[2] polyPlaneExtractOffset; updatePerformPolyCutOffset; } global proc performPolyCutCallback (string $parent, int $doIt) { string $prefix = "polyCut"; setParent $parent; optionVar -intValue "polyPlaneCutDirection" (`radioButtonGrp -query -sl polyPlaneCutDirection`); optionVar -intValue "polyPlaneDeleteFaces" `checkBoxGrp -query -value1 polyPlaneDeleteFaces`; optionVar -intValue "polyPlaneExtractFaces" `checkBoxGrp -query -value1 polyPlaneExtractFaces`; optionVar -floatValue "polyPlaneExtractOffset" `floatFieldGrp -query -value1 polyPlaneExtractOffset` -floatValueAppend "polyPlaneExtractOffset" `floatFieldGrp -query -value2 polyPlaneExtractOffset` -floatValueAppend "polyPlaneExtractOffset" `floatFieldGrp -query -value3 polyPlaneExtractOffset`; if ($doIt) { performPolyCut 0; addToRecentCommandQueue "performPolyCut 0" "PolyCut"; } } proc polyCutOptions (string $prefix) { // Global template variables for form spacing global int $gOptionBoxTemplateFrameSpacing; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; waitCursor -state 1; string $commandName = "performPolyCut"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Form layout string $parent = `formLayout polyCutFaceOptions`; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performPolyCut.kSettingsFrame"))`; columnLayout; radioButtonGrp -nrb 4 -label (uiRes("m_performPolyCut.kCutDirections")) -vr -cc updatePerformPolyCutTRS -label1 (uiRes("m_performPolyCut.kCutDirections1")) -da1 0 -label2 (uiRes("m_performPolyCut.kCutDirections2")) -da2 1 -label3 (uiRes("m_performPolyCut.kCutDirections3")) -da3 2 -label4 (uiRes("m_performPolyCut.kCutDirections4")) -da4 3 polyPlaneCutDirection; separator -style "none"; checkBoxGrp -label1 (uiRes("m_performPolyCut.kDeleteCutFaces")) -onc "checkBoxGrp -e -value1 off polyPlaneExtractFaces; updatePerformPolyCutOffset" polyPlaneDeleteFaces; checkBoxGrp -label1 (uiRes("m_performPolyCut.kExtractCutFaces")) -cc updatePerformPolyCutOffset polyPlaneExtractFaces; floatFieldGrp -label (uiRes("m_performPolyCut.kDeleteOffset")) -numberOfFields 3 polyPlaneExtractOffset; setParent ..; // columnLayout setParent $parent; // frameLayout setParent ..; // formLayout // Attach frame 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_performPolyCut.kApplyButton")) -command ($callback + " " + $parent + " " + 1) $applyBtn; string $applyCloseBtn = getOptionBoxApplyAndCloseBtn(); button -edit -label (uiRes("m_performPolyCut.kApplyAndCloseButton")) $applyCloseBtn; string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; setOptionBoxTitle( (uiRes("m_performPolyCut.kCutFaceOptions")) ); setOptionBoxHelpTag("CutFaces"); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } proc string assembleCmd() { setOptionVars (false); int $doHistory = `constructionHistory -q -toggle`; //string $cmd=("polyCut -ch " + $doHistory); string $cmd = "polyCut "; $cmd += " -ws 1 "; int $ival=`optionVar -query "polyPlaneCutDirection"`; if ($ival == 1) { // Interactive Cut $cmd = "setToolTo polyCutContext;"; return $cmd; } else { if ($ival == 2) $cmd+=(" -cd \"X\""); else if ($ival == 3) $cmd+=(" -cd \"Y\""); else if ($ival == 4) $cmd+=(" -cd \"Z\""); } if (`optionVar -query "polyPlaneDeleteFaces"`) { $cmd += " -df 1"; } else if (`optionVar -query "polyPlaneExtractFaces"`) { $cmd += " -ef 1"; float $off[]=`optionVar -query "polyPlaneExtractOffset"`; $cmd += (" -eox " + $off[0] + " -eoy " + $off[1] + " -eoz " + $off[2]); } return $cmd; } global proc string performPolyCut (int $option) { string $prefix = "polyCut"; string $cmd=""; switch ($option) { case 0: string $varName; int $ival; setOptionVars(false); $cmd=`assembleCmd`; if ($cmd == "setToolTo polyCutContext;") { string $editCmd = "\npolyCutCtx -e "; if (`optionVar -query "polyPlaneDeleteFaces"`) $editCmd += "-df 1 "; else $editCmd += "-df 0 "; if (`optionVar -query "polyPlaneExtractFaces"`) { $editCmd += "-ef 1 "; float $off[]=`optionVar -query "polyPlaneExtractOffset"`; $editCmd += "-eo " + $off[0] + " " + $off[1] + " " + $off[2] + " "; } else { $editCmd += "-ef 0 "; } $editCmd += " polyCutContext;"; $cmd += $editCmd; eval($cmd); break; } else { polyPerformAction $cmd "f" 0; } if ( 0 != size(`ls -sl`) || (0 != size(`ls -hl`)) ) { string $tmp[] = `listHistory`; string $totalSel[]; for ($opNode in $tmp) { if (`nodeType $opNode` == "polyCut") { $totalSel[size($totalSel)] = $opNode; } } if (size($totalSel) > 0) select -add $totalSel[0]; global string $gPolyLastTool; $gPolyLastTool=""; setToolTo ShowManips; } break; case 1: polyCutOptions($prefix); break; case 2: $cmd="performPolyCut 0"; break; } return $cmd; }