// =========================================================================== // 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. // =========================================================================== proc setOptionVars (int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists "splitPolyWithCurveOperation"`) optionVar -intValue "splitPolyWithCurveOperation" 1; if ($forceFactorySettings || !`optionVar -exists "splitPolyWithCurveTolerance"`) optionVar -fv "splitPolyWithCurveTolerance" 0.001; } global proc performSplitMeshWithProjectedCurveSetup (string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $selection = `optionVar -q "splitPolyWithCurveOperation"`; if ($selection < 1 || $selection > 2) $selection = 1; radioButtonGrp -edit -select $selection splitMeshWithProjectedCurveOperation; float $tolerance = `optionVar -q "splitPolyWithCurveTolerance"`; floatFieldGrp -e -v1 $tolerance splitMeshWithProjectedCurveTolerance; } global proc performSplitMeshWithProjectedCurveCallback (string $parent, int $doIt) { setParent $parent; int $operation = `radioButtonGrp -q -select splitMeshWithProjectedCurveOperation`; optionVar -intValue "splitPolyWithCurveOperation" $operation; float $tolerance = `floatFieldGrp -q -v1 splitMeshWithProjectedCurveTolerance`; optionVar -fv "splitPolyWithCurveTolerance" $tolerance; if ($doIt) { performSplitMeshWithProjectedCurve 0; addToRecentCommandQueue "performSplitMeshWithProjectedCurve 0" "SplitMeshWithProjectedCurve"; } } global proc splitMeshWithProjectedCurveOptions() { global int $gOptionBoxTemplateFrameSpacing; string $layout = getOptionBox(); setParent $layout; setUITemplate -pushTemplate OptionBoxTemplate; string $commandName = "performSplitMeshWithProjectedCurve"; string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Form layout string $parent = `formLayout splitMeshWithProjectedCurveOptions`; // Settings frame string $settingsFrame = `frameLayout -label (uiRes("m_performSplitMeshWithProjectedCurve.kSettingsFrame"))`; columnLayout; radioButtonGrp -numberOfRadioButtons 2 -vertical -label "" -label1 (uiRes("m_performSplitMeshWithProjectedCurve.kJustSplit")) -label2 (uiRes("m_performSplitMeshWithProjectedCurve.kSplitAndSeparate")) splitMeshWithProjectedCurveOperation; floatFieldGrp -l (uiRes("m_performSplitMeshWithProjectedCurve.kTolerance")) splitMeshWithProjectedCurveTolerance; 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; setUITemplate -popTemplate; string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSplitMeshWithProjectedCurve.kApplyButton")) -command ($callback + " " + $parent + " " + 1) $applyBtn; string $applyCloseBtn = getOptionBoxApplyAndCloseBtn(); button -edit -label (uiRes("m_performSplitMeshWithProjectedCurve.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_performSplitMeshWithProjectedCurve.kSplitMeshWithCurveOptions")) ); setOptionBoxHelpTag("SplitMeshWithProjectedCurve"); eval (($setup + " " + $parent + " " + 0)); showOptionBox(); } proc string assembleCmd() { global int $gSelectMeshesBit; global int $gSelectNurbsCurvesBit; string $meshList[] = `filterExpand -ex true -sm $gSelectMeshesBit`; string $curveList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit`; if (0 < `size $meshList` && 0 < `size $curveList`) { string $cmd = ("polySplit"); int $detachEdges = `optionVar -q "splitPolyWithCurveOperation"`; $cmd += (" -detachEdges " + (1 != $detachEdges)); float $tolerance = `optionVar -q "splitPolyWithCurveTolerance"`; $cmd += (" -projectedCurveTolerance " + $tolerance); for ($curve in $curveList) { $cmd += (" -projectedCurve " + $curve); } $cmd += (" " + $meshList[0]); return $cmd; } return ""; } global proc string performSplitMeshWithProjectedCurve(int $operation) { string $cmd=""; switch ($operation) { case 0: setOptionVars(false); $cmd = `assembleCmd`; eval($cmd); break; case 1: splitMeshWithProjectedCurveOptions(); break; case 2: $cmd = "performSplitMeshWithProjectedCurve 0"; break; } return $cmd; }