// =========================================================================== // 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: Sept 25, 1998 // // Description: // This script defines the option box for the sweep surface menu item. // // Input Arguments: // int action // 0 - show the option box dialog // 1 - just execute the sweep operation // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // sweepUseComponentPivot (int) - can be 1|0 for user specified or use // start of path. // if ($forceFactorySettings || !`optionVar -exists sweepUseComponentPivot`) { optionVar -intValue sweepUseComponentPivot 0; } // only if user specified. // if ($forceFactorySettings || !`optionVar -exists sweepUsePivotX`) { optionVar -floatValue sweepUsePivotX 0.0; } if ($forceFactorySettings || !`optionVar -exists sweepUsePivotY`) { optionVar -floatValue sweepUsePivotY 0.0; } if ($forceFactorySettings || !`optionVar -exists sweepUsePivotZ`) { optionVar -floatValue sweepUsePivotZ 0.0; } // extrude style is TUBE(2) by default. // other options : distance(0), flat(1). // if ($forceFactorySettings || !`optionVar -exists sweepStyle`) { optionVar -intValue sweepStyle 2; } // extrude path fixed or shape (1) fixed. // if ($forceFactorySettings || !`optionVar -exists sweepPathFixed`) { optionVar -intValue sweepPathFixed 0; } // use profile normal. // Only for distance extrude. // if ($forceFactorySettings || !`optionVar -exists sweepUseProfileNormal`) { optionVar -intValue sweepUseProfileNormal 1; } // extrude direction. // X axis (0), Y axis (1), Z axis (2) & user Defined (3). // if ($forceFactorySettings || !`optionVar -exists sweepDirectionType`) { optionVar -intValue sweepDirectionType 0; } if ($forceFactorySettings || !`optionVar -exists sweepDirectionX`) { optionVar -floatValue sweepDirectionX 0.0; } if ($forceFactorySettings || !`optionVar -exists sweepDirectionY`) { optionVar -floatValue sweepDirectionY 1.0; } if ($forceFactorySettings || !`optionVar -exists sweepDirectionZ`) { optionVar -floatValue sweepDirectionZ 0.0; } // extrude length. // only for distance style extrude. // if ($forceFactorySettings || !`optionVar -exists sweepLength`) { optionVar -floatValue sweepLength 1.0 ; } // sweep rotation // if ($forceFactorySettings || !`optionVar -exists sweepRotation`) { optionVar -floatValue sweepRotation 0.0 ; } // sweep scale. // if ($forceFactorySettings || !`optionVar -exists sweepScale`) { optionVar -floatValue sweepScale 1.0 ; } // sweepCurveRangePartial (int) - either 0|1 for using the complete // curve or only a partial curve for the operation. // if ($forceFactorySettings || !`optionVar -exists sweepCurveRangePartial`){ optionVar -intValue sweepCurveRangePartial 0; } // sweepOutputPolygons (int) - 0|1 for polygon or Nurbs output // if ($forceFactorySettings || !`optionVar -exists sweepOutputPolygons`){ optionVar -intValue sweepOutputPolygons 0; } } global proc sweepVisibility( string $parent, int $vector, int $style, int $direction ) { setParent $parent; if( $style < 0 ) $style = `radioButtonGrp -q -sl style_B`; switch( $style ) { case 1: // distance tabLayout -e -st distOptions_C swapOptions_T; break; case 2: // flat tabLayout -e -st sweepTubeOptions_C swapOptions_T; radioButtonGrp -e -en false pivot_B; radioButtonGrp -e -en false dirType_RX; break; case 3: // tube default: tabLayout -e -st sweepTubeOptions_C swapOptions_T; radioButtonGrp -e -en true pivot_B; radioButtonGrp -e -en true dirType_RX; break; } if( $direction < 0 ) $direction = `radioButtonGrp -q -sl dirType_R`; switch( $direction ) { case 1: // specify direction // radioButtonGrp -e -en true direction_R; if( $vector < 0 ) $vector = `radioButtonGrp -q -select direction_R`; switch( $vector ) { case 1: // x axis floatFieldGrp -e -en false -v1 1.0 -v2 0.0 -v3 0.0 userDir_F; break; case 2: // y axis floatFieldGrp -e -en false -v1 0.0 -v2 1.0 -v3 0.0 userDir_F; break; case 3: // z axis floatFieldGrp -e -en false -v1 0.0 -v2 0.0 -v3 1.0 userDir_F; break; case 0: // free axis default: floatFieldGrp -e -en true userDir_F; break; } break; case 2: // use profile normal as direction // default: radioButtonGrp -e -en false direction_R; floatFieldGrp -e -en false userDir_F; break; } } proc string assembleCmd() // // Description : // To assemble sweep proc. // { setOptionVars(false); string $cmd = "performSweepPreset"; int $history = `constructionHistory -q -tgl`; int $range = `optionVar -q sweepCurveRangePartial`; int $pivotType = `optionVar -q sweepUseComponentPivot`; int $polygons = `optionVar -q sweepOutputPolygons`; int $extrudeType = `optionVar -q sweepStyle`; int $pathFixed = `optionVar -q sweepPathFixed`; int $useProfileNormal = `optionVar -q sweepUseProfileNormal`; float $dirx = 0.0; float $diry = 0.0; float $dirz = 0.0; int $dir = `optionVar -q sweepDirectionType`; switch ($dir) { case 0 : $dirx = 1.0; $diry = 0.0; $dirz = 0.0; break; case 1 : $dirx = 0.0; $diry = 1.0; $dirz = 0.0; break; case 2 : $dirx = 0.0; $diry = 0.0; $dirz = 1.0; break; default : $dirx = `optionVar -q sweepDirectionX`; $diry = `optionVar -q sweepDirectionY`; $dirz = `optionVar -q sweepDirectionZ`; break; } float $distance = 0.0; $distance = `optionVar -q sweepLength`; float $rotation = 0.0; $rotation = `optionVar -q sweepRotation`; float $scale = 1.0; $scale = `optionVar -q sweepScale`; $cmd = $cmd + "("; $cmd = $cmd + $history; $cmd = $cmd + ","; $cmd = $cmd + $range; $cmd = $cmd + ","; $cmd = $cmd + $polygons; $cmd = $cmd + ","; $cmd = $cmd + $extrudeType; $cmd = $cmd + ","; $cmd = $cmd + $pivotType; $cmd = $cmd + ","; $cmd = $cmd + $pathFixed; $cmd = $cmd + ","; $cmd = $cmd + $useProfileNormal; $cmd = $cmd + ","; $cmd = $cmd + $dirx; $cmd = $cmd + ","; $cmd = $cmd + $diry; $cmd = $cmd + ","; $cmd = $cmd + $dirz; $cmd = $cmd + ","; $cmd = $cmd + $distance; $cmd = $cmd + ","; $cmd = $cmd + $rotation; $cmd = $cmd + ","; $cmd = $cmd + $scale; $cmd = $cmd + ")"; return $cmd; } proc sweepOptions() { // Name of the command for this option box. // string $realCommandName = "extrude"; string $commandName = "sweep"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Step 1: Get the option box. // ============================ string $layout = getOptionBox(); setParent $layout; // Step 2: Pass the command name to the option box. // ================================================= setOptionBoxCommandName($realCommandName); // 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`; radioButtonGrp -nrb 3 -sl 3 -l (uiRes("m_performSweep.kStyle")) -l1 (uiRes("m_performSweep.kDistance")) -da1 0 -l2 (uiRes("m_performSweep.kFlat")) -da2 1 -l3 (uiRes("m_performSweep.kTube")) -da3 2 -on1 ("sweepVisibility " + $parent + " -1 1 -1" ) -on2 ("sweepVisibility " + $parent + " -1 2 -1" ) -on3 ("sweepVisibility " + $parent + " -1 3 -1" ) style_B; tabLayout -tabsVisible false swapOptions_T; columnLayout distOptions_C; floatSliderGrp -l "Extrude Length" -min 0.0 -max 10.0 -fmn -1e8 -fmx 1e8 length_F; radioButtonGrp -nrb 2 -sl 2 -l (uiRes("m_performSweep.kDirection")) -l1 (uiRes("m_performSweep.kSpecify")) -da1 0 -l2 (uiRes("m_performSweep.kProfileNormal")) -da2 1 -on1 ("radioButtonGrp -e -select 1 dirType_RX;" + "sweepVisibility " + $parent + " -1 -1 1") -on2 ("radioButtonGrp -e -select 2 dirType_RX;" + "sweepVisibility " + $parent + " -1 -1 2") dirType_R; radioButtonGrp -nrb 4 -l (uiRes("m_performSweep.kDirectionVector")) -l1 (uiRes("m_performSweep.kXAxis")) -l2 (uiRes("m_performSweep.kYAxis")) -l3 (uiRes("m_performSweep.kZAxis")) -l4 (uiRes("m_performSweep.kFree")) -on1 ("sweepVisibility " + $parent + " 1 -1 -1") -on2 ("sweepVisibility " + $parent + " 2 -1 -1") -on3 ("sweepVisibility " + $parent + " 3 -1 -1") -on4 ("sweepVisibility " + $parent + " 0 -1 -1") direction_R; floatFieldGrp -l "" -nf 3 userDir_F; setParent ..; columnLayout sweepTubeOptions_C; radioButtonGrp -nrb 2 -sl 1 -l (uiRes("m_performSweep.kResultPosition")) -l1 (uiRes("m_performSweep.kAtProfile")) -da1 0 -l2 (uiRes("m_performSweep.kAtPath")) -da2 1 path_B; radioButtonGrp -nrb 2 -sl 1 -l (uiRes("m_performSweep.kPivot")) -l1 (uiRes("m_performSweep.kClosestEndPoint")) -da1 0 -l2 (uiRes("m_performSweep.kComponent")) -da2 1 pivot_B; radioButtonGrp -nrb 2 -sl 2 -l (uiRes("m_performSweep.kOrientation")) -l1 (uiRes("m_performSweep.kPathDirection")) -da1 0 -l2 (uiRes("m_performSweep.kProfileNormal")) -da2 1 -on1 ("radioButtonGrp -e -select 1 dirType_R;" + "sweepVisibility " + $parent + " -1 -1 1") -on2 ("radioButtonGrp -e -select 2 dirType_R;" + "sweepVisibility " + $parent + " -1 -1 2") dirType_RX; setParent ..; setParent ..; floatSliderGrp -l "Rotation" -field true -min 0.0 -max 360.0 -fmn -1000000.0 -fmx 1000000.0 sweepRotateField; floatSliderGrp -l "Scale" -field true -min 0.0 -max 10.0 -fmn -1000.0 -fmx 1000.0 sweepScaleField; // layout for add curve range, create as polygons. // separator; radioButtonGrp -nrb 2 -label (uiRes("m_performSweep.kCurveRange")) -label1 (uiRes("m_performSweep.kComplete")) -da1 0 -label2 (uiRes("m_performSweep.kPartial")) -da2 1 range_R; radioButtonGrp -nrb 2 -label (uiRes("m_performSweep.kOutputGeometry")) -label1 (uiRes("m_performSweep.kNurbs")) -da1 0 -label2 (uiRes("m_performSweep.kPolygons")) -da2 1 -cc1 "tabLayout -e -vis false polyOptions" // there are currently no NURBS options -cc2 "tabLayout -e -vis true polyOptions" poly_B; separator; tabLayout -tabsVisible false polyOptions; string $par = `columnLayout polyOptionsOK`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; // 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(); button -edit -l "Sweep" -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle("Sweep Options"); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } proc string sweepHelp() { string $cmdHelp = (uiRes("m_performSweep.kHelpSweptSurface")); string $selectHelp = (uiRes("m_performSweep.kHelpSelection")); return $cmdHelp+$selectHelp; } global proc sweepSetup( string $parent, int $forceFactorySettings ) { // retrieve option settings. // setOptionVars($forceFactorySettings); setParent $parent; // query all the option vars. // int $extrudeType = `optionVar -q sweepStyle`; int $pathFixed = `optionVar -q sweepPathFixed`; int $range = `optionVar -q sweepCurveRangePartial`; int $polygons = `optionVar -q sweepOutputPolygons`; //set controls. // radioButtonGrp -edit -select ($extrudeType+1) style_B; radioButtonGrp -edit -select ($pathFixed+1) path_B; radioButtonGrp -edit -select ($range+1) range_R; radioButtonGrp -edit -select ($polygons+1) poly_B; int $pivot = `optionVar -q sweepUseComponentPivot`; radioButtonGrp -edit -select ($pivot+1) pivot_B; int $useProfileNormal = `optionVar -q sweepUseProfileNormal`; radioButtonGrp -edit -select ($useProfileNormal+1) dirType_R; radioButtonGrp -edit -select ($useProfileNormal+1) dirType_RX; // user specified normal ? // int $dirType = `optionVar -q sweepDirectionType`; radioButtonGrp -edit -select ($dirType+1) direction_R; float $x = `optionVar -q sweepDirectionX`; float $y = `optionVar -q sweepDirectionY`; float $z = `optionVar -q sweepDirectionZ`; floatFieldGrp -e -v1 $x userDir_F; floatFieldGrp -e -v2 $y userDir_F; floatFieldGrp -e -v3 $z userDir_F; float $length = `optionVar -q sweepLength`; floatSliderGrp -e -v $length length_F; float $rotate = `optionVar -q sweepRotation`; floatSliderGrp -e -v $rotate sweepRotateField; float $scale = `optionVar -q sweepScale`; floatSliderGrp -e -v $scale sweepScaleField; sweepVisibility $parent -1 -1 -1; if( $polygons ) { tabLayout -e -vis true polyOptions; } else { tabLayout -e -vis false polyOptions; // there are currently no NURBS options } nurbsToPolySetup( $parent, $forceFactorySettings ); } global proc sweepCallback( string $parent, int $doIt ) { setParent $parent; // get Values from controls. // int $range = `radioButtonGrp -q -select range_R` - 1; int $extrudeType = `radioButtonGrp -q -select style_B` - 1; int $pathFixed = `radioButtonGrp -q -select path_B` - 1; int $polygons = `radioButtonGrp -q -select poly_B` - 1; int $pivot = `radioButtonGrp -q -select pivot_B` - 1; int $useProfileNormal = `radioButtonGrp -q -select dirType_R` - 1; optionVar -intValue sweepUseProfileNormal $useProfileNormal; if( $extrudeType == 0 ) { if( $useProfileNormal == 0 ) { int $direction = `radioButtonGrp -q -select direction_R` - 1; optionVar -intValue sweepDirectionType $direction; // user specified direction. // if( $direction == 3 ) { float $x = `floatFieldGrp -q -v1 userDir_F`; float $y = `floatFieldGrp -q -v2 userDir_F`; float $z = `floatFieldGrp -q -v3 userDir_F`; optionVar -floatValue sweepDirectionX $x; optionVar -floatValue sweepDirectionY $y; optionVar -floatValue sweepDirectionZ $z; } } // extrude length. // float $length = `floatSliderGrp -q -v length_F`; optionVar -floatValue sweepLength $length; } float $rotate = `floatSliderGrp -q -v sweepRotateField`; optionVar -floatValue sweepRotation $rotate; float $scale = `floatSliderGrp -q -v sweepScaleField`; optionVar -floatValue sweepScale $scale; optionVar -intValue sweepStyle $extrudeType; optionVar -intValue sweepPathFixed $pathFixed; optionVar -intValue sweepCurveRangePartial $range; optionVar -intValue sweepOutputPolygons $polygons; // extrude Type is Tube. // if( $extrudeType == 2 ) { optionVar -intValue sweepUseComponentPivot $pivot; } nurbsToPolyCallback( $parent, 0 ); if( $doIt ) { performSweep(0); addToRecentCommandQueue "performSweep(0)" "Sweep"; } } global proc string performSweep( int $action ) // // Description : // $action = 0 ==> do the command. // $action = 1 ==>show option box. // $action = 2 ==>drag to shelf. { string $cmd = ""; switch( $action ) { case 0 : // do the cmd. $cmd = `assembleCmd`; eval $cmd; break; case 1 : // show option box. // sweepOptions(); break; case 2 : // drag to shelf the proc. // $cmd = `assembleCmd`; break; default : break; } return $cmd; }