// =========================================================================== // 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 28, 1997 // // Description: // The offsetCosPreset() procedure executes a offset cos operation on // a cos based on the offset option vars. // // Input Arguments: // None. // // Return Value: // None. // proc string pieceTogetherOffsetCosCmd( int $history, int $curvePartial, int $connectBreaks, int $stitch, int $cutLoop, float $distance, float $tolerance, int $subdivisionDensity) // // Description : // Piece together a offsetCos command. // { string $cmd; $cmd = "offsetCurveOnSurface "; // construction history $cmd = $cmd + " -ch "; if ( $history == 1 ) $cmd = $cmd + "on"; else $cmd = $cmd + "off"; // curve range. // $cmd = $cmd + " -rn " ; if( $curvePartial == 1 ) $cmd = $cmd + "true" ; else $cmd = $cmd + "false" ; // connect breaks $cmd = $cmd + " -cb " + $connectBreaks; // stitch if ( $stitch == 1 ) $cmd = $cmd + " -st true"; else $cmd = $cmd + " -st false"; // cut loops if ( $cutLoop == 1 ) $cmd = $cmd + " -cl true"; else $cmd = $cmd + " -cl false"; // offset distance $cmd = $cmd + " -d " + $distance; // offset tolerance $cmd = $cmd + " -tol " + $tolerance; // subdivision density $cmd = $cmd + " -sd " + $subdivisionDensity; return $cmd; } global proc offsetCosPreset( int $history, int $curvePartial, int $connectBreaks, int $stitch, int $cutLoop, float $distance, float $tolerance, int $subdivisionDensity) // // offsetCos with the preset options. // Use this proc when operation dragged to Shelf. // { // Get the list of nurbs cos selected. Works for curves on surface // Do this here because addViewNormal creates a node which will blow away the // selection list // global int $gSelectNurbsCurvesBit; global int $gSelectCurvesOnSurfacesBit; global int $gSelectSurfaceEdgeBit; global int $gSelectIsoparmsBit; string $curvesList[] = `filterExpand -ex true -sm $gSelectCurvesOnSurfacesBit -sm $gSelectSurfaceEdgeBit -sm $gSelectIsoparmsBit`; // build the command string $cmd = pieceTogetherOffsetCosCmd($history, $curvePartial, $connectBreaks, $stitch, $cutLoop, $distance, $tolerance, $subdivisionDensity); // placeholder for one selection item int $nitems = 1; $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $nitems ); int $numCurves = size($curvesList) ; if( $numCurves < 1 ) { string $msg = (uiRes("m_offsetCosPreset.kSelectError")); error($msg); } else { // compute each offset in turn string $offsetResults[]; string $curve[1]; for( $i = 0 ; $i < $numCurves ; $i++ ) { $curve[0] = $curvesList[$i]; string $results[] = executeCmdOnItems( $cmd, $curve ); $offsetResults = stringArrayCatenate($offsetResults, $results); } // select the results. // int $resultCount = size($offsetResults); if ( $resultCount > 0 ) { string $selectString; $selectString = "select -r "; int $i; for ( $i = 0; $i < $resultCount; $i++ ) { $selectString += $offsetResults[$i]; $selectString += " "; } $selectString += ";"; select -cl; eval($selectString); } } }