// =========================================================================== // 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. // =========================================================================== // // // Description : // To make a nurbs square as one curve. // global proc int makeNurbsSquareOneCurve() // // Description : To create a NURBS square as one curve. // Uses the global construction history status to // keep/delete history. // { int $i, $error ; $error = 0; // 1. create nurbsSquare node // string $sqNode ; if ( catch ($sqNode = `createNode makeNurbsSquare`) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorNodeCreationFailed")); return 1 ; } // 2. create 3 attachCurve nodes. // string $attachNode[3] ; $attachNode[0] = "" ; $attachNode[1] = "" ; $attachNode[2] = "" ; for( $i = 0 ; $i < 3 ; $i++ ) { string $n ; if( catch ($n = `createNode attachCurve`) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorNodeCreationFailed")); $error = 1 ; } else { $attachNode[$i] = $n ; } } // 3. clean up if error. // if( $error ) { delete $sqNode ; for( $i = 0 ; $i < 3 ;$i++ ) { if( $attachNode[$i] != "" ) delete $attachNode[$i] ; } return 1; } // 4. wire up square node 0, 1 output curves with attach node[0] // string $inAttr = $sqNode + ".oc1"; string $outAttr = $attachNode[0] + ".ic1"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectToAttachNodeFailed")) ; return 1 ; } $inAttr = $sqNode + ".oc2"; $outAttr = $attachNode[0] + ".ic2"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectToAttachNodeFailed")) ; return 1 ; } // 4. wire up square node attrib oc2, // output curve of attach node[0] to attachNode[1]. // $inAttr = $attachNode[0] + ".oc"; $outAttr = $attachNode[1] + ".ic1"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectAttachNodesFailed")) ; return 1 ; } // 5. wire up square node attrib oc3, // output curve of attach node[1] to attachNode[2]. // $inAttr = $sqNode + ".oc3"; $outAttr = $attachNode[1] + ".ic2"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectToAttachNodeFailed")) ; return 1 ; } $inAttr = $attachNode[1] + ".oc"; $outAttr = $attachNode[2] + ".ic1"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectAttachNodesFailed")) ; return 1 ; } $inAttr = $sqNode + ".oc4"; $outAttr = $attachNode[2] + ".ic2"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectSquare4Failed")) ; return 1 ; } // 6. wire up attachNode[2] attrib oc to curveShape .cr // string $crv ; $crv = `createNode nurbsCurve` ; $inAttr = $attachNode[2] + ".oc"; $outAttr = $crv + ".cr"; if( catch( `connectAttr $inAttr $outAttr` ) ) { error (uiRes("m_makeNurbsSquareOneCurve.kErrorConnectNodeToCurveFailed")) ; return 1 ; } select -r $crv ; // 7. History or no history. // int $doHistory = `constructionHistory -q -toggle` ; if( $doHistory == 0 ) { $outAttr = $crv + ".ws[0]" ; refresh ; delete -ch ; } return $error ; }