// =========================================================================== // 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 1, 1997 // // Description: // The extrudePreset() procedure executes one or more extrude operations on // a curve shapes based on the extrude option vars. In general if // you have n curve shapes selected, (n-1) extrude operations would be // carried out. // // Input Arguments: // None. // // Return Value: // None. // proc string pieceTogetherExtrudeCmd( int $doHistory, int $curvePartial, int $asPolygons, int $extrudeType, int $pivotType, int $pathFixed, int $profileNormal, float $dirX, float $dirY, float $dirZ, float $distance ) // // Description : // Put together an extrude Cmd. // { string $cmd = "extrude" ; // history. // $cmd = $cmd + " -ch " ; if( $doHistory == 1 ) $cmd = $cmd + "true" ; else $cmd = $cmd + "false" ; // curve range. // $cmd = $cmd + " -rn " ; if( $curvePartial == 1 ) $cmd = $cmd + "true" ; else $cmd = $cmd + "false" ; // polygon output. // $cmd = $cmd + " -po " ; $cmd = $cmd + $asPolygons ; // extrude type. // distance (0), flat (1), tube (2). // $cmd = $cmd + " -et " ; $cmd = $cmd + $extrudeType; // pivot type. // ( only for extrudeType "tube". ) // if( $extrudeType == 2 ) { $cmd = $cmd + " -ucp " ; $cmd = $cmd + $pivotType; } // is Path Fixed or shape. // ( only for tube, flat ). // if( $extrudeType != 0 ) { $cmd = $cmd + " -fpt " ; $cmd = $cmd + $pathFixed ; } $cmd = $cmd + " -upn " ; $cmd = $cmd + $profileNormal; // query use profile Normal, length // Only for distance extrude. // if( $extrudeType == 0 ) { if( $profileNormal == 0 ) { $cmd = $cmd + " -d " ; $cmd = $cmd + $dirX ; $cmd = $cmd + " " ; $cmd = $cmd + $dirY ; $cmd = $cmd + " " ; $cmd = $cmd + $dirZ ; } $cmd = $cmd + " -length " ; $cmd = $cmd + $distance ; } return $cmd ; } global proc extrudePreset( int $doHistory, int $curvePartial, int $asPolygons, int $extrudeType, int $pivotType, int $pathFixed, int $profileNormal, // valid only if extrudeType is distance. float $dirX, float $dirY, float $dirZ, float $distance ) // // Description : // Proc to do one or more extrude depending on number // of valid selection items. // { //--------------------------------------- // put together an extrude cmd. //--------------------------------------- // string $cmd = pieceTogetherExtrudeCmd( $doHistory, $curvePartial, $asPolygons, $extrudeType, $pivotType, $pathFixed, $profileNormal, $dirX, $dirY, $dirZ, $distance ) ; //---------------------------------------- // place holders for 2 selection items. //---------------------------------------- // int $nitems = 2 ; int $oneArg = 0 ; if( $extrudeType == 0 ) { $nitems = $nitems - 1 ; $oneArg = 1 ; } $cmd = appendToCmdPlaceHoldersForSelectionItems($cmd,$nitems) ; //--------------------------------------------- // Get the list of nurbs curves in select list. //--------------------------------------------- // global int $gSelectNurbsCurvesBit; global int $gSelectIsoparmsBit; global int $gSelectCurvesOnSurfacesBit; global int $gSelectSurfaceEdgeBit; global int $gSelectMeshEdge; string $curveList[] = `filterExpand -ex true -sm $gSelectMeshEdge -sm $gSelectNurbsCurvesBit -sm $gSelectIsoparmsBit -sm $gSelectCurvesOnSurfacesBit -sm $gSelectSurfaceEdgeBit`; //-------------------------------------------- // Valid # of items. //-------------------------------------------- // int $curveCount = size($curveList) ; if( ($nitems == 2 && $curveCount < 2) ) { error ((uiRes("m_extrudePreset.kErrorSelectMoreCurves")) ); } else if( ($nitems == 1 && $curveCount < 1) ) { error ((uiRes("m_extrudePreset.kErrorSelectAtLeastOneCurve")) ); } else { // all (n-1) combinations. // The last item is the path. // string $extrudeResults[] ; int $nr = size($extrudeResults) ; int $i ; if( $oneArg == 0 ) { string $curvePair[2] ; // the path curve shape is the last item. // $curvePair[1] = $curveList[$curveCount-1] ; for( $i = 0 ; $i < ($curveCount-1) ; $i++ ) { $curvePair[0] = $curveList[$i] ; string $results[] = executeCmdOnItems($cmd,$curvePair); $extrudeResults = stringArrayCatenate($extrudeResults, $results); } // for $i } else { // flat extrude by distance in a specified direction. // string $curvePair[1] ; for( $i = 0 ; $i < $curveCount ; $i++ ) { $curvePair[0] = $curveList[$i] ; string $results[] = executeCmdOnItems($cmd,$curvePair); $extrudeResults = stringArrayCatenate($extrudeResults, $results); } // for $i } // select the results. // int $resultCount = size($extrudeResults) ; if( $resultCount > 0 ) { string $selectString; $selectString = "select -r "; for( $i = 0 ; $i < $resultCount ; $i++ ) { $selectString += $extrudeResults[$i] ; $selectString += " "; } $selectString += ";" ; eval($selectString) ; } } }