// =========================================================================== // 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: April 24, 1997 // // Description: // This script is defines the option box for the projectTangent menu item. // // Input Arguments: // int action // 0 - show the option box dialog // 1 - just execute the projectTangent operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { projectTangentSetOptionVars( $forceFactorySettings ); } global proc projectTangentSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // retrieve option settings. // setOptionVars($forceFactorySettings); projectTangentToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // query all the option vars. // int $keepOriginal = `optionVar -q projectTangentKeepOriginal` ; checkBoxGrp -edit -v1 $keepOriginal projectTangentKeepOriginalBoxGrp ; // tangent or curvature. // int $keepCurvature = `optionVar -q projectTangentKeepCurvature` + 1 ; radioButtonGrp -edit -select $keepCurvature projectTangentTypeButtonGrp ; // reverse tangent. // int $revTangent = `optionVar -q projectTangentReverseValue` ; checkBoxGrp -edit -v1 $revTangent projectTangentReverseTangentBoxGrp ; // align Tangent Direction. // int $alignTangent = `optionVar -q projectTangentAlignDirection` ; radioButtonGrp -edit -select $alignTangent projectTangentAlignButtonGrp ; // query the tangent scale value. // float $scale = `optionVar -q projectTangentTangentScaleValue` ; floatSliderGrp -edit -value $scale projectTangentScaleSlider ; // query the curvature scale value. // $scale = `optionVar -q projectTangentCurvatureScale` ; floatSliderGrp -edit -value $scale projectTangentCurvatureScaleSlider ; $scale = `optionVar -q projectTangentRotation` ; floatSliderGrp -edit -value $scale projectTangentRotationSlider ; if( 1 == $keepCurvature ) { tabLayout -e -selectTab curvatureOffOptions projectTangentSwapOptions; } else { tabLayout -e -selectTab curvatureOnOptions projectTangentSwapOptions; } switch( $alignTangent ) { case 1: tabLayout -e -selectTab normalDirOffOptions projectTangentDirectionOptions; break; case 2: tabLayout -e -selectTab normalDirOffOptions projectTangentDirectionOptions; break; case 3: default: tabLayout -e -selectTab normalDirOnOptions projectTangentDirectionOptions; break; } if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } global proc projectTangentCallback( string $parent, int $doIt, string $goToTool ) // // Description : // { if( "" != $goToTool ) { optionVar -iv projectTangentEuc `scriptCtx -q -euc $goToTool`; optionVar -iv projectTangentLac `scriptCtx -q -lac $goToTool`; } setParent $parent ; // get and set factory Values from user controls. // int $keepOriginal = `checkBoxGrp -q -v1 projectTangentKeepOriginalBoxGrp`; optionVar -intValue projectTangentKeepOriginal $keepOriginal ; int $keepCurvature = `radioButtonGrp -q -select projectTangentTypeButtonGrp`-1; optionVar -intValue projectTangentKeepCurvature $keepCurvature ; int $revTangent = `checkBoxGrp -q -v1 projectTangentReverseTangentBoxGrp`; optionVar -intValue projectTangentReverseValue $revTangent ; int $alignDirection = `radioButtonGrp -q -select projectTangentAlignButtonGrp`; optionVar -intValue projectTangentAlignDirection $alignDirection ; float $value = `floatSliderGrp -q -value projectTangentScaleSlider` ; optionVar -floatValue projectTangentTangentScaleValue $value ; $value = `floatSliderGrp -q -value projectTangentCurvatureScaleSlider` ; optionVar -floatValue projectTangentCurvatureScale $value ; $value = `floatSliderGrp -q -value projectTangentRotationSlider` ; optionVar -floatValue projectTangentRotation $value ; if( 1 == $doIt ) { performProjectTangent(0, $goToTool) ; string $tmpCmd = "performProjectTangent(0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Project Tangent"; } else if( $doIt ) { setToolTo $goToTool; } } proc createProjectTangentUI( string $parent, int $inTheTool, string $goToTool ) // // Description : // projectCurve operation options { setParent $parent ; string $tabLayoutName = `setParent -q` + "|projectTangentSwapOptions"; string $tabLayout2Name = `setParent -q` + "|projectTangentDirectionOptions"; // curvature or tangent. // radioButtonGrp -nrb 2 -select 1 -label (uiRes("m_performProjectTangent.kConstruction")) -label1 (uiRes("m_performProjectTangent.kTangent")) -da1 0 -label2 (uiRes("m_performProjectTangent.kCurvature")) -da2 1 -on1 ("tabLayout -e -selectTab curvatureOffOptions " + "\"" + $tabLayoutName + "\"" + ";") -on2 ("tabLayout -e -selectTab curvatureOnOptions " + "\"" + $tabLayoutName + "\"" + ";") projectTangentTypeButtonGrp ; // align direction. // radioButtonGrp -nrb 3 -select 1 -label (uiRes("m_performProjectTangent.kTangentAlignDirection")) -label1 (uiRes("m_performProjectTangent.kU")) -da1 1 -label2 (uiRes("m_performProjectTangent.kV")) -da2 2 -label3 (uiRes("m_performProjectTangent.kNormal")) -da3 3 -on1 ("tabLayout -e -selectTab normalDirOffOptions " + "\"" + $tabLayout2Name + "\"" + ";") -on2 ("tabLayout -e -selectTab normalDirOffOptions " + "\"" + $tabLayout2Name + "\"" + ";") -on3 ("tabLayout -e -selectTab normalDirOnOptions " + "\"" + $tabLayout2Name + "\"" + ";") projectTangentAlignButtonGrp ; // reverse Tangent. // checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performProjectTangent.kReverseDirection")) projectTangentReverseTangentBoxGrp; separator; // scale Tangent. // columnLayout tangentAdjustment; floatSliderGrp -field true -min -10.0 -max 10.0 -label (uiRes("m_performProjectTangent.kTangentScale")) projectTangentScaleSlider; setParent ..; tabLayout -tabsVisible false projectTangentDirectionOptions; columnLayout normalDirOffOptions; floatSliderGrp -field true -min 0.0 -max 360 -fieldMinValue -360 -fieldMaxValue 360 -label (uiRes("m_performProjectTangent.kTangentRotation")) projectTangentRotationSlider; setParent ..; columnLayout normalDirOnOptions; setParent ..; setParent ..; tabLayout -tabsVisible false projectTangentSwapOptions; columnLayout curvatureOffOptions; setParent ..; columnLayout curvatureOnOptions; floatSliderGrp -field true -min -10.0 -max 10.0 -label (uiRes("m_performProjectTangent.kCurvatureScale")) projectTangentCurvatureScaleSlider; setParent ..; setParent ..; separator; checkBoxGrp -ncb 1 -label "" -label1 (uiRes("m_performProjectTangent.kKeepOriginal")) projectTangentKeepOriginalBoxGrp ; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performProjectTangent.kToolBehavior")) -label1 (uiRes("m_performProjectTangent.kExitOnCompletion")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performProjectTangent.kAutoCompletion")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } } proc string assembleCmd() // // Description : // To assemble projectTangent proc. // { setOptionVars(false); string $cmd = "projectTangentPreset" ; $cmd = $cmd + "(" ; int $history = `constructionHistory -q -tgl`; $cmd = $cmd + $history ; $cmd = $cmd + "," ; int $keepOriginal = `optionVar -q projectTangentKeepOriginal` ; $cmd = $cmd + $keepOriginal ; $cmd = $cmd + "," ; int $keepCurvature = `optionVar -q projectTangentKeepCurvature` ; $cmd = $cmd + $keepCurvature ; $cmd = $cmd + "," ; int $reverseTangent = `optionVar -q projectTangentReverseValue` ; $cmd = $cmd + $reverseTangent ; $cmd = $cmd + "," ; int $alignTangent = `optionVar -q projectTangentAlignDirection` ; $cmd = $cmd + $alignTangent ; $cmd = $cmd + "," ; float $scale = `optionVar -q projectTangentTangentScaleValue` ; $cmd = $cmd + $scale ; $cmd = $cmd + "," ; $scale = `optionVar -q projectTangentCurvatureScale` ; $cmd = $cmd + $scale ; $cmd = $cmd + "," ; $scale = `optionVar -q projectTangentRotation` ; $cmd = $cmd + $scale ; $cmd = $cmd + "," ; int $ignoreEdges = 0; $cmd = $cmd + $ignoreEdges ; $cmd = $cmd + ")" ; return $cmd ; } proc projectTangentOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "projectTangent"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolProjectTangent"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "projectTangentToolScript 3"; // Step 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // Step 2: Pass the command name to the option box. // ================================================= setOptionBoxCommandName($commandName); // Step 3: Activate the default UI template. // ========================================== setUITemplate -pushTemplate DefaultTemplate; // Step 4: Create option box contents. // =================================== // Turn on the wait cursor. // waitCursor -state 1; tabLayout -scr true -tv false; string $parent = `columnLayout -adjustableColumn 1`; createProjectTangentUI( $parent, $inTheTool, $goToTool ); // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); if( $inTheTool ) { button -edit -label (uiRes("m_performProjectTangent.kProjectTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performProjectTangent.kProject")) -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"") $applyBtn; } // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " 0 \"" + $goToTool + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"") $resetBtn; // Step 7: Set the option box title. // ================================= // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performProjectTangent.kProjectTangentToolOptions")); } else { setOptionBoxTitle (uiRes("m_performProjectTangent.kProjectTangentOptions")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "ProjectTangent" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string projectTangentHelp() { string $help = "Command: projectTangent - projects and tangent " + "align a NURBS curve on to a NURBS surface. \n" + "Select : curve to project and align and a surface."; return $help ; } global proc string performProjectTangent( int $action, string $goToTool ) // // Description : // $action = 0 ==> do the command. // $action = 1 ==>show option box. // $action = 2 ==>drag to shelf. { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = "" ; switch( $action ) { case 0 : $cmd = `assembleCmd` ; eval $cmd ; break ; case 1 : projectTangentOptions( $inTheTool, $goToTool ) ; break ; case 2 : default: $cmd = `assembleCmd` ; break ; } return $cmd ; }