// =========================================================================== // 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 20, 1997 // // Description: // The intersectPreset() procedure executes a intersect operation on // a pair of surfaces based on the intersect option vars. In general if // you have n surfaces selected, (n-1) surface intersect operations would // be carried out. // // Input Arguments: // None. // // Return Value: // None. // proc string pieceTogetherACmd( int $cosOnlyOnFirstSurface, int $cosAs2D, int $history, float $tol ) // // Description : // piece together an intersect command. // { string $cmd; $cmd = "intersect " ; // construction history. // $cmd = $cmd + " -ch " ; if( $history == 1 ) { $cmd = $cmd + "true" ; } else { $cmd = $cmd + "false" ; } $cmd = $cmd + " -fs " ; $cmd = $cmd + $cosOnlyOnFirstSurface ; $cmd = $cmd + " -cos " ; $cmd = $cmd + $cosAs2D ; $cmd = $cmd + " -tol " + $tol ; return $cmd ; } global proc intersectPreset( int $cosOnlyOnFirstSurface, int $cosAs2D, int $history, float $tol ) // // Intersect with the preset options. // Use this proc when operation dragged to Shelf. // { string $cmd ; $cmd = pieceTogetherACmd( $cosOnlyOnFirstSurface, $cosAs2D, $history, $tol ) ; int $nitems = 2 ; $cmd = appendToCmdPlaceHoldersForSelectionItems($cmd,$nitems) ; // Get the list of nurbs surfaces selected. // global int $gSelectNurbsSurfacesBit; string $surfaceList[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit`; int $i ; int $surfaceCount = size($surfaceList) ; if( $surfaceCount < 2 ) { error (uiRes("m_intersectPreset.kIntersectSurfInvalSelection")); } else { // all (n-1) combinations // string $intersectResults[] ; int $nr = size($intersectResults) ; for( $i = 0 ; $i < $surfaceCount-1 ; $i++ ) { string $surfacePair[2] ; $surfacePair[0] = $surfaceList[$i] ; $surfacePair[1] = $surfaceList[$surfaceCount-1] ; string $results[] = executeCmdOnItems( $cmd, $surfacePair ); $intersectResults = stringArrayCatenate( $intersectResults, $results ) ; } // for $i // select the results. // int $resultCount = size($intersectResults) ; if( $resultCount > 0 ) { string $selectString; $selectString = "select -r"; // select all results to begin with // $resultCount = size($intersectResults) ; for( $i = 0 ; $i < $resultCount ; $i++ ) { $selectString += " "; $selectString += $intersectResults[$i] ; } $selectString += ";"; eval($selectString) ; } } }