// =========================================================================== // 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: Mar 14, 1997 // // Description: // This script is defines the option box for the rebuild surface menu item. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { rebuildSurfaceSetOptionVars( $forceFactorySettings ); } // // Procedure Name: // rebuildSurfaceVisibility // // Description: // Depending on the options, some other options do or do not show. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // Return Value: // None. // proc int getRebuildType() // Description: // Return the "1" based rebuild type. { int $rebType = `radioButtonGrp -q -select rebuildTypeRadioGroup1`; if( 0 == $rebType ) { $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup2`; if( 0 == $rebType ) { $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup3`; if( 0 == $rebType ) { if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ){ $rebType = 2; } else { $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup4`; } $rebType += 2; } $rebType += 2; } $rebType += 2; } return $rebType; } global proc rebuildSurfaceVisibility( string $parent, int $useGlobalTol, int $rebuildType, int $keepCVs, int $keepNumSpans ) { if( $useGlobalTol < 0 ) { $useGlobalTol = `radioButtonGrp -q -select toleranceRadioButtonGrp`; } if( $rebuildType < 0 ) { $rebuildType = getRebuildType(); } if( $keepCVs < 0 ) { $keepCVs = `checkBoxGrp -q -v2 keepCheckBoxGrp`; } if( $keepNumSpans < 0 ) { $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`; } // can only show slider of not keeping CVs or numSpans int $showCVslider = ((!$keepCVs) && (!$keepNumSpans)); int $matchKnots = false; switch( $rebuildType ) { case 1: default: // Uniform (0 for the attribute) intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp; intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp; checkBoxGrp -e -en true keepCheckBoxGrp; checkBoxGrp -e -en1 (!$keepCVs) -en2 true -en3 (!$keepCVs) keepCheckBoxGrp; radioButtonGrp -e -en true directionRadioButtonGrp; frameLayout -e -collapse false uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse true endKnotsLayout; break; case 2: // Reduce (1 for the attribute) checkBoxGrp -e -en false keepCheckBoxGrp; frameLayout -e -collapse true uniformTypeLayout; frameLayout -e -collapse false toleranceLayout; radioButtonGrp -e -en true directionRadioButtonGrp; if( $useGlobalTol == 1 ) { tabLayout -e -vis false localToleranceTabLayout; } else { tabLayout -e -vis true localToleranceTabLayout; } frameLayout -e -collapse true endKnotsLayout; break; case 3: // Match (2 for the attribute) $matchKnots = true; checkBoxGrp -e -en true keepCheckBoxGrp; // keep numspans must be disabled for match knots checkBoxGrp -e -en1 true -en2 true -en3 false keepCheckBoxGrp; radioButtonGrp -e -en true directionRadioButtonGrp; frameLayout -e -collapse true uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse true endKnotsLayout; break; case 4: // Remove multiple (3 for the attribute) checkBoxGrp -e -en false keepCheckBoxGrp; // no direction option for nonrational - always does both radioButtonGrp -e -en false directionRadioButtonGrp; frameLayout -e -collapse true uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse true endKnotsLayout; break; case 5: // force non-rational (4 for the attribute) checkBoxGrp -e -en false keepCheckBoxGrp; // no direction option for no mult - always does both radioButtonGrp -e -en false directionRadioButtonGrp; frameLayout -e -collapse true uniformTypeLayout; frameLayout -e -collapse false toleranceLayout; if( $useGlobalTol == 1 ) { tabLayout -e -vis false localToleranceTabLayout; } else { tabLayout -e -vis true localToleranceTabLayout; } frameLayout -e -collapse true endKnotsLayout; break; case 6: // rebuild ends (5 for the attribute) checkBoxGrp -e -en false keepCheckBoxGrp; radioButtonGrp -e -en true directionRadioButtonGrp; frameLayout -e -collapse true uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse false endKnotsLayout; break; case 7: // trim convert (6 for the attribute) intSliderGrp -e -en true numSpansUIntSliderGrp; intSliderGrp -e -en true numSpansVIntSliderGrp; checkBoxGrp -e -en true keepCheckBoxGrp; checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp; radioButtonGrp -e -en false directionRadioButtonGrp; frameLayout -e -collapse false uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse true endKnotsLayout; break; case 8: // bezier (7 for the attribute) intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp; intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp; checkBoxGrp -e -en true keepCheckBoxGrp; checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp; radioButtonGrp -e -en false directionRadioButtonGrp; frameLayout -e -collapse false uniformTypeLayout; frameLayout -e -collapse true toleranceLayout; frameLayout -e -collapse true endKnotsLayout; break; } radioButtonGrp -e -en ($matchKnots) fitRebuildRadioButtonGrp; } // // Procedure Name: // rebuildSurfaceSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc rebuildSurfaceSetup( string $parent, int $forceFactorySettings, string $goToTool ) { // Retrieve the option settings // setOptionVars($forceFactorySettings); rebuildSurfaceToolSetup( $forceFactorySettings, $goToTool ); setParent $parent; // Query the optionVar's and set the values into the controls. // Query the optionVar's and set the values into the controls // int $rebuildType = `optionVar -q rebuildSurfaceType` + 1; int $numSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`; int $numSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`; int $degreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`; int $degreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`; int $keepRange = `optionVar -q rebuildSurfaceKeepRange`; int $direction = `optionVar -q rebuildSurfaceDirection`; int $endKnots = `optionVar -q rebuildSurfaceEndKnots`; int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`; int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`; int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`; int $useGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`; radioButtonGrp -e -select (2 - $useGlobalTol) toleranceRadioButtonGrp; float $localTol = `optionVar -q rebuildSurfaceLocalTolerance`; int $keepOriginal = `optionVar -q rebuildSurfaceKeepOriginal`; int $polys = `optionVar -q rebuildSurfacePolys`; int $fitRebuild = `optionVar -q rebuildSurfaceFitRebuild`; // Set the controls // if( (1 == $rebuildType) || (2 == $rebuildType) ) { radioButtonGrp -e -select $rebuildType rebuildTypeRadioGroup1; } else if( $rebuildType == 3 || $rebuildType == 4 ) { int $temp = $rebuildType - 2; radioButtonGrp -e -select $temp rebuildTypeRadioGroup2; } else if( $rebuildType == 5 || $rebuildType == 6 ) { int $temp = $rebuildType - 4; radioButtonGrp -e -select $temp rebuildTypeRadioGroup3; } else { int $temp = $rebuildType - 6; if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ) { $temp = 1; optionVar -iv rebuildSurfaceType 7; } radioButtonGrp -e -select $temp rebuildTypeRadioGroup4; } intSliderGrp -e -value $numSpansU numSpansUIntSliderGrp; intSliderGrp -e -value $numSpansV numSpansVIntSliderGrp; switch($degreeU) { case 1: radioButtonGrp -e -select 1 rebuildSrfUDegree123; break; case 2: radioButtonGrp -e -select 2 rebuildSrfUDegree123; break; case 3: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break; case 5: radioButtonGrp -e -select 1 rebuildSrfUDegree57; break; case 7: radioButtonGrp -e -select 2 rebuildSrfUDegree57; break; case 0: radioButtonGrp -e -select 3 rebuildSrfUDegree57; break; default: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break; } switch($degreeV) { case 1: radioButtonGrp -e -select 1 rebuildSrfVDegree123; break; case 2: radioButtonGrp -e -select 2 rebuildSrfVDegree123; break; case 3: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break; case 5: radioButtonGrp -e -select 1 rebuildSrfVDegree57; break; case 7: radioButtonGrp -e -select 2 rebuildSrfVDegree57; break; case 0: radioButtonGrp -e -select 3 rebuildSrfVDegree57; break; default: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break; } radioButtonGrp -e -select ($endKnots+1) endKnotsRadioButtonGrp; radioButtonGrp -e -select ($keepRange+1) keepRangeRadioButtonGrp; radioButtonGrp -e -select ($direction+1) directionRadioButtonGrp; checkBoxGrp -e -value1 $keepCornerPts keepCheckBoxGrp; checkBoxGrp -e -value2 $keepControlPoints keepCheckBoxGrp; checkBoxGrp -e -value3 $keepNumSpans keepCheckBoxGrp; radioButtonGrp -e -select $useGlobalTol toleranceRadioButtonGrp; floatSliderGrp -e -value $localTol localTolFloatFieldGrp; checkBoxGrp -e -value1 $keepOriginal keepOriginalCheckBox; // No "Bezier" option on the geometry output, as you just // want the NURBS that is rebuilt as Bezier. if( 3 == $polys ) $polys = 0; radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp; // Nurbs or poly ? // switch( $polys ) { case 0: default: frameLayout -e -cl true geomOptionLP; break; case 1: frameLayout -e -cl false geomOptionLP; break; case 2: frameLayout -e -cl true geomOptionLP; break; } // Fit/Rebuild setting // switch ( $fitRebuild ) { case 1: // The "Least Squares fit" case. This option is not available // through the UI for the Rebuild Surfaces panel, so we should // never get here, but just in case, we fall though. // case 0: default: // Convert Classic: This is the standard and default convert // method which uses a least squares fit if either operand // surface is periodic. // radioButtonGrp -e -select 1 fitRebuildRadioButtonGrp; break; case 2: // Convert Match: Alternate rebuild algorithm which may // give better results with periodic surfaces. // radioButtonGrp -e -select 2 fitRebuildRadioButtonGrp; break; } nurbsToPolySetup( $parent, $forceFactorySettings ); nurbsToSubdivSetup( $parent, $forceFactorySettings ); rebuildSurfaceVisibility $parent $useGlobalTol $rebuildType $keepControlPoints $keepNumSpans; if( "" != $goToTool ) { checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool` scriptToolExtraWidget; checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool` scriptToolExtraWidget; } } // // Procedure Name: // rebuildSurfaceCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc rebuildSurfaceCallback( string $parent, int $doIt, string $goToTool ) { setParent $parent; // Set the optionVar's from the current control values, and then perform // the command // int $rebuildType = getRebuildType(); int $numSpansU = `intSliderGrp -q -value numSpansUIntSliderGrp`; int $numSpansV = `intSliderGrp -q -value numSpansVIntSliderGrp`; int $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfUDegree123`; int $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfUDegree57`; int $degreeU; switch($degreeBtn123) { case 1: $degreeU = 1; break; case 2: $degreeU = 2; break; case 3: $degreeU = 3; break; default: switch($degreeBtn57) { case 1: $degreeU = 5; break; case 2: $degreeU = 7; break; case 3: $degreeU = 0; break; default: $degreeU = 3; break; } break; } $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfVDegree123`; $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfVDegree57`; int $degreeV; switch($degreeBtn123) { case 1: $degreeV = 1; break; case 2: $degreeV = 2; break; case 3: $degreeV = 3; break; default: switch($degreeBtn57) { case 1: $degreeV = 5; break; case 2: $degreeV = 7; break; case 3: $degreeV = 0; break; default: $degreeV = 3; break; } break; } int $endKnots = `radioButtonGrp -q -select endKnotsRadioButtonGrp` - 1; int $keepRange = `radioButtonGrp -q -select keepRangeRadioButtonGrp` - 1; int $direction = `radioButtonGrp -q -select directionRadioButtonGrp` - 1; int $keepCornerPts = `checkBoxGrp -q -v1 keepCheckBoxGrp`; int $keepControlPoints = `checkBoxGrp -q -v2 keepCheckBoxGrp`; int $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`; int $useGlobalTol = 2 - `radioButtonGrp -q -select toleranceRadioButtonGrp`; float $localtol = `floatSliderGrp -q -value localTolFloatFieldGrp`; int $keepOrig = `checkBoxGrp -q -v1 keepOriginalCheckBox`; int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp` - 1; int $fitRebuild = `radioButtonGrp -q -select fitRebuildRadioButtonGrp`; if ( 1 == $fitRebuild ) { $fitRebuild = 0; // Convert Classic } else if ( 2 == $fitRebuild ) { $fitRebuild = 2; // Convert Match } optionVar -intValue rebuildSurfaceType ($rebuildType-1); optionVar -intValue rebuildSurfaceTypeUniformNumSpansU $numSpansU; optionVar -intValue rebuildSurfaceTypeUniformNumSpansV $numSpansV; optionVar -intValue rebuildSurfaceTypeUniformDegreeU $degreeU; optionVar -intValue rebuildSurfaceTypeUniformDegreeV $degreeV; optionVar -intValue rebuildSurfaceEndKnots $endKnots; optionVar -intValue rebuildSurfaceKeepRange $keepRange; optionVar -intValue rebuildSurfaceDirection $direction; optionVar -intValue rebuildSurfaceKeepControlPoints $keepControlPoints; optionVar -intValue rebuildSurfaceKeepCornerPoints $keepCornerPts; optionVar -intValue rebuildSurfaceKeepNumSpans $keepNumSpans; optionVar -intValue rebuildSurfaceUseGlobalTolerance $useGlobalTol; optionVar -floatValue rebuildSurfaceLocalTolerance $localtol; optionVar -intValue rebuildSurfaceKeepOriginal $keepOrig; optionVar -intValue rebuildSurfacePolys $polygons; optionVar -intValue rebuildSurfaceFitRebuild $fitRebuild; nurbsToPolyCallback( $parent, 0 ); nurbsToSubdivCallback( $parent, 0 ); if( 1 == $doIt ) { performRebuildSurface( 0, $goToTool ); string $tmpCmd = "performRebuildSurface( 0, \"" + $goToTool + "\")"; addToRecentCommandQueue $tmpCmd "Rebuild Surfaces"; } else if( $doIt ) { setToolTo $goToTool; } } // // Procedure Name: // rebuildSurfaceOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc rebuildSurfaceOptions( int $inTheTool, string $goToTool ) { // Name of the command for this option box. // string $commandName = "rebuildSurface"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); global string $gOptionBoxActionToolItem; $gOptionBoxActionToolItem = "modelWithToolRebuildSurface"; global string $gOptionBoxActionToolItemCB; $gOptionBoxActionToolItemCB = "rebuildSurfaceToolScript 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`; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRebuildSurface.kRebuildType")) -label1 (uiRes("m_performRebuildSurface.kUniform")) -label2 (uiRes("m_performRebuildSurface.kReduce")) rebuildTypeRadioGroup1; string $noMultipleKnots = (uiRes("m_performRebuildSurface.kNoMultipleKnots")); radioButtonGrp -shareCollection rebuildTypeRadioGroup1 -numberOfRadioButtons 2 -label "" -label1 (uiRes("m_performRebuildSurface.kMatchknots")) -label2 $noMultipleKnots rebuildTypeRadioGroup2; radioButtonGrp -shareCollection rebuildTypeRadioGroup1 -numberOfRadioButtons 2 -label "" -label1 (uiRes("m_performRebuildSurface.kNonRational")) -label2 (uiRes("m_performRebuildSurface.kEndConditionsOption")) rebuildTypeRadioGroup3; string $bezier = (uiRes("m_performRebuildSurface.kBezier")); int $hasTrimConvert = `licenseCheck -m edit -typ model`; if( $hasTrimConvert ) { radioButtonGrp -shareCollection rebuildTypeRadioGroup1 -numberOfRadioButtons 2 -label "" -label1 (uiRes("m_performRebuildSurface.kTrimConvert")) -label2 $bezier rebuildTypeRadioGroup4; } else { radioButtonGrp -shareCollection rebuildTypeRadioGroup1 -numberOfRadioButtons 1 -label "" -label1 $bezier rebuildTypeRadioGroup4; } separator; // tab for end conditions frameLayout -bv false -lv false endKnotsLayout; columnLayout endKnotsGroups; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRebuildSurface.kEndConditions")) -label1 $noMultipleKnots -label2 (uiRes("m_performRebuildSurface.kMultipleKnots")) endKnotsRadioButtonGrp; setParent ..; setParent ..; radioButtonGrp -nrb 3 -label (uiRes("m_performRebuildSurface.kParameterRange")) -label1 (uiRes("m_performRebuildSurface.kZerotoOne")) -label2 (uiRes("m_performRebuildSurface.kKeepOption")) -label3 (uiRes("m_performRebuildSurface.kSpans")) keepRangeRadioButtonGrp; string $uAxis = (uiRes("m_performRebuildSurface.kUAxis")); string $vAxis = (uiRes("m_performRebuildSurface.kVAxis")); string $both = (uiRes("m_performRebuildSurface.kBoth")); radioButtonGrp -nrb 3 -label (uiRes("m_performRebuildSurface.kDirection")) -label1 $uAxis -label2 $vAxis -label3 $both directionRadioButtonGrp; checkBoxGrp -ncb 3 -label (uiRes("m_performRebuildSurface.kKeep")) -label1 (uiRes("m_performRebuildSurface.kCorners")) -label2 (uiRes("m_performRebuildSurface.kCVs")) -label3 (uiRes("m_performRebuildSurface.kNumSpans")) -on2 ("rebuildSurfaceVisibility " + $parent + " -1 -1 1 -1") -of2 ("rebuildSurfaceVisibility " + $parent + " -1 -1 0 -1") -on3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1 1") -of3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1 0") keepCheckBoxGrp; radioButtonGrp -nrb 2 -label (uiRes("m_performRebuildSurface.kRebuildMethod")) -label1 (uiRes("m_performRebuildSurface.kClassic")) -label2 (uiRes("m_performRebuildSurface.kMatch")) fitRebuildRadioButtonGrp; frameLayout -bv false -lv false uniformTypeLayout; columnLayout uniformTypeSliders; intSliderGrp -label (uiRes("m_performRebuildSurface.kNumberofSpansU")) -min 0 -max 100 -fmx 5000 -field on numSpansUIntSliderGrp; intSliderGrp -label (uiRes("m_performRebuildSurface.kNumberofSpansV")) -min 0 -max 100 -fmx 5000 -field on numSpansVIntSliderGrp; string $original = (uiRes("m_performRebuildSurface.kOriginal")); string $linear = (uiRes("m_performRebuildSurface.kLinear")); string $quadratic = (uiRes("m_performRebuildSurface.kQuadratic")); string $cubic = (uiRes("m_performRebuildSurface.kCubic")); string $quintic = (uiRes("m_performRebuildSurface.kQuintic")); string $seven = (uiRes("m_performRebuildSurface.kSeven")); radioButtonGrp -label (uiRes("m_performRebuildSurface.kDegreeU")) -numberOfRadioButtons 3 -label1 $linear -label2 $quadratic // Quadratic -label3 $cubic -select 3 rebuildSrfUDegree123; radioButtonGrp -shareCollection rebuildSrfUDegree123 -numberOfRadioButtons 3 -label1 $quintic // Quintic -label2 $seven -label3 $original rebuildSrfUDegree57; radioButtonGrp -label (uiRes("m_performRebuildSurface.kDegreeV")) -numberOfRadioButtons 3 -label1 $linear -label2 $quadratic // Quadratic -label3 $cubic -select 3 rebuildSrfVDegree123; radioButtonGrp -shareCollection rebuildSrfVDegree123 -numberOfRadioButtons 3 -label1 $quintic // Quintic -label2 $seven -label3 $original rebuildSrfVDegree57; setParent ..; setParent ..; separator; checkBoxGrp -ncb 1 -label1 (uiRes("m_performRebuildSurface.kKeepOriginal")) keepOriginalCheckBox; frameLayout -bv false -lv false toleranceLayout; columnLayout toleranceGroups; radioButtonGrp -numberOfRadioButtons 2 -label (uiRes("m_performRebuildSurface.kUseTolerance")) -label1 (uiRes("m_performRebuildSurface.kGlobal")) -label2 (uiRes("m_performRebuildSurface.kLocal")) toleranceRadioButtonGrp; tabLayout -tabsVisible false localToleranceTabLayout; columnLayout localToleranceSlider; floatSliderGrp -label (uiRes("m_performRebuildSurface.kPositionalTolerance")) -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0 localTolFloatFieldGrp; setParent ..; setParent ..; setParent ..; setParent ..; // Set the tolerance radio button up so that when "Global" is // selected, then the local tolerance slider is disabled. // When "Local" is selected then the local tolerance slider is enabled. // radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " 1 -1 -1 -1") -cc2 ("rebuildSurfaceVisibility " + $parent + " 0 -1 -1 -1") toleranceRadioButtonGrp; // Set the layout that contains the number of spans slider and // the degree slider so that only displays stuff when the type is Uniform. // radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 1 -1 -1") -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 2 -1 -1") rebuildTypeRadioGroup1; radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 3 -1 -1") -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 4 -1 -1") rebuildTypeRadioGroup2; radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 5 -1 -1") -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 6 -1 -1") rebuildTypeRadioGroup3; if( $hasTrimConvert ) { radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 7 -1 -1") -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1") rebuildTypeRadioGroup4; } else { radioButtonGrp -e -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1") rebuildTypeRadioGroup4; } string $nurbs = (uiRes("m_performRebuildSurface.kNURBS")); string $polygons = (uiRes("m_performRebuildSurface.kPolygons")); string $outputGeometry = (uiRes("m_performRebuildSurface.kOutputGeometry")); if( `isTrue "SubdivUIExists"` ) { radioButtonGrp -numberOfRadioButtons 3 -label $outputGeometry -label1 $nurbs -label2 $polygons -label3 (uiRes("m_performRebuildSurface.kSubdiv")) -cc1 "frameLayout -e -cl true geomOptionLP" -cc2 "frameLayout -e -cl false geomOptionLP" -cc3 "frameLayout -e -cl true geomOptionLP" outputPolyRadioButtonGrp; } else { radioButtonGrp -numberOfRadioButtons 2 -label $outputGeometry -label1 $nurbs -label2 $polygons -cc1 "frameLayout -e -cl true geomOptionLP" -cc2 "frameLayout -e -cl false geomOptionLP" outputPolyRadioButtonGrp; } string $par; frameLayout -bv false -lv false geomOptionLP; $par = `columnLayout geomOptionP`; nurbsToPolyAddOptions $par; setParent ..; setParent ..; if( $inTheTool ) { separator; checkBoxGrp -ncb 2 -label (uiRes("m_performRebuildSurface.kToolBehavior")) -label1 (uiRes("m_performRebuildSurface.kExit")) -v1 off -on1 ("scriptCtx -e -euc true " + $goToTool) -of1 ("scriptCtx -e -euc false " + $goToTool) -label2 (uiRes("m_performRebuildSurface.kAuto")) -v2 on -on2 ("scriptCtx -e -lac true " + $goToTool) -of2 ("scriptCtx -e -lac false " + $goToTool) scriptToolExtraWidget; } // 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_performRebuildSurface.kRebuildTool")) -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"") $applyBtn; } else { button -edit -label (uiRes("m_performRebuildSurface.kRebuild")) -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"") $applyBtn; } // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -e -command ($callback + " " + $parent + " 0 \"" + $goToTool + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -e -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"") $resetBtn; // Step 7: Set the option box title. // ================================= // if( $inTheTool ) { setOptionBoxTitle (uiRes("m_performRebuildSurface.kSurfaceToolTitle")); } else { setOptionBoxTitle (uiRes("m_performRebuildSurface.kSurfaceTitle")); } // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "RebuildSurfaces" ); // Step 9: Set the current values of the option box. // ================================================= // eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\""); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // rebuildSurfaceHelp // // Description: // Return a short description about this command. // // Input Arguments: // None. // // Return Value: // string. // proc string rebuildSurfaceHelp() { return " Command: Rebuild Surface - perform surface rebuild\n" + "Selection: surface"; } global proc performRebuildSurfacePreset() { rebuildSurfaceSetOptionVars( false ); int $doHistory = `constructionHistory -q -tgl`; int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`; int $rebuildType = `optionVar -q rebuildSurfaceType`; float $globalTol = `optionVar -q positionalTolerance`; int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`; int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`; int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`; int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`; int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`; int $endKnots = `optionVar -q rebuildSurfaceEndKnots`; int $direction = `optionVar -q rebuildSurfaceDirection`; int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`; int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`; int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`; int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`; float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`; int $polys = `optionVar -q rebuildSurfacePolys`; int $fitRebuild = `optionVar -q rebuildSurfaceFitRebuild`; if( $keepNumSpans ) { $srfNumSpansU = 0; $srfNumSpansV = 0; } performRebuildSurfaceSet( $doHistory, $replaceOriginal, $rebuildType, $globalTol, $srfNumSpansU, $srfNumSpansV, $srfDegreeU, $srfDegreeV, $endKnots, $keepParmRange, $keepCornerPts, $keepControlPoints, $direction, $srfUseGlobalTol, $srfLocalTol, $polys, $fitRebuild ); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd = "performRebuildSurfaceSet"; setOptionVars(false); int $doHistory = `constructionHistory -q -tgl`; int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`; int $rebuildType = `optionVar -q rebuildSurfaceType`; float $globalTol = `optionVar -q positionalTolerance`;; int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`; int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`; int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`; int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`; int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`; int $endKnots = `optionVar -q rebuildSurfaceEndKnots`; int $direction = `optionVar -q rebuildSurfaceDirection`; int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`; int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`; int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`; int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`; float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`; int $polys = `optionVar -q rebuildSurfacePolys`; int $fitRebuild = `optionVar -q rebuildSurfaceFitRebuild`; if( $keepNumSpans ) { $srfNumSpansU = 0; $srfNumSpansV = 0; } $cmd = ( $cmd + " " + $doHistory + " " + $replaceOriginal + " " + $rebuildType + " " + $globalTol + " " + $srfNumSpansU + " " + $srfNumSpansV + " " + $srfDegreeU + " " + $srfDegreeV + " " + $endKnots + " " + $keepParmRange + " " + $keepCornerPts + " " + $keepControlPoints + " " + $direction + " " + $srfUseGlobalTol + " " + $srfLocalTol + " " + $polys + " " + $fitRebuild ); return $cmd; } // // Procedure Name: // performRebuildSurface // // Description: // Perform the rebuildSurface command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the rebuildSurface command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performRebuildSurface(int $action, string $goToTool) { int $inTheTool = false; if( 3 == $action ) { $action = 1; $inTheTool = true; } string $cmd = ""; switch ($action) { case 0: setOptionVars(false); $cmd = `assembleCmd`; eval($cmd); break; case 1: rebuildSurfaceOptions( $inTheTool, $goToTool ); break; case 2: default: setOptionVars (false); $cmd = `assembleCmd`; break; } return $cmd; }