// =========================================================================== // 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 17, 1997 // // Description: // The doAttachCurveArgList() procedure executes an attach curve operation // on a pair of curves based on the attach option vars. In general // if you have n curves selected, only the last 2 curves would // be attached. // // Versions: // "1" is Maya V1, Maya V1.5 // "2" is Maya V2. // proc string pieceTogetherAttachCmd( string $version, string $args[] ) // // Description : // Piece together an attach command. // { string $cmd = ""; int $need = 0; if( "1" == $version ) { $need = 3; } else if( "2" == $version ) { $need = 7; } else { string $msg = (uiRes("m_doAttachCurveArgList.kBadVersion")); warning( $msg ); $version = "1"; $need = 3; } if( size($args) < $need ) { string $msg = (uiRes("m_doAttachCurveArgList.kNotEnoughArgs")); error( $msg ); return $cmd; } $cmd = "attachCurve "; // construction history $cmd = $cmd + " -ch " + $args[0]; $cmd = $cmd + " -rpo " + $args[1]; $cmd = $cmd + " -kmk " + $args[2]; if( "2" == $version ) { $cmd = $cmd + " -m " + $args[3]; $cmd = $cmd + " -bb " + $args[4]; $cmd = $cmd + " -bki " + $args[5]; $cmd = $cmd + " -p " + $args[6]; } return $cmd; } global proc doAttachCurveArgList( string $version, string $args[] ) // // attach with the preset options. // Use this proc when operation dragged to Shelf. // { string $cmd = pieceTogetherAttachCmd( $version, $args ); if( "" == $cmd ) return; int $history = $args[0]; int $replaceOriginal = $args[1]; // Get the list of nurbs curves selected. // global int $gSelectNurbsCurvesBit; global int $gSelectCurvesOnSurfacesBit; global int $gSelectCurveParmPointsBit; string $curvesList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit -sm $gSelectCurvesOnSurfacesBit -sm $gSelectCurveParmPointsBit`; int $numCurves = size($curvesList); $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $numCurves ); if ( $numCurves == 0 ) { string $msg = (uiRes("m_doAttachCurveArgList.kNeedPairs")); error($msg); } else if ( $numCurves == 1 ) { string $msg = (uiRes("m_doAttachCurveArgList.kNotEnoughCurves")); error($msg); } else if ( $numCurves > 1 ) { if ( $history == 0 && $replaceOriginal == 1 ) { // delete history on each input to attach cmd (so that command // won't force history on) // string $buffer[]; for($i=0; $i<$numCurves; $i++) { tokenize($curvesList[$i], ".", $buffer); string $curveName = $buffer[0]; $buffer = `listHistory -pdo 1 $curveName`; if ( size($buffer) > 0 ) { // the curve has history so delete it // string $msg = (uiRes("m_doAttachCurveArgList.kDeletHistory")); warning(`format -stringArg $curveName $msg`); evalEcho("delete -ch " + $curveName); } } } string $results[] = executeCmdOnItems( $cmd, $curvesList ); // select the results. // int $resultCount = size($results); if ( $resultCount > 0 ) { string $selectString; $selectString = "select "; if ( $replaceOriginal ) { if ( $history == 0 ) { // delete the second curve since it is no longer required evalEcho("delete " + $results[1]); } else { // make the second curve an intermediate object (so that // the user won't ever see it). Note: can't do "delete" // here or else attach result will go away due to history // on. // string $resultShapes[] = `listRelatives -s $results[1]`; int $shapeCount = size($resultShapes); if ( $shapeCount > 0 ) { evalEcho("setAttr " + $resultShapes[0] + ".io true"); } } $selectString += $results[0]; } else { int $i; for ( $i = 0; $i < $resultCount; $i++ ) { $selectString += $results[$i]; $selectString += " "; } } $selectString += ";"; select -cl; eval($selectString); } } }