// =========================================================================== // 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. // =========================================================================== // Utility functions proc string clipToGhostFromCharacter( string $scheduler ) { string $characters[] = `clipSchedule -q -ch $scheduler`; if ( size($characters) == 0 ) return ""; string $conns[] = `listConnections -type clipToGhostData -d 1 -s 0 $characters[0]`; return ( size($conns) ) ? $conns[0] : ""; } // Main entry point/function // // Procedure Name: // getClipToGhostForScheduler // // Description: // Determine the clipToGhost node connected to a named scheduler. // // Input Arguments: // $scheduler: The scheduler for which we'd like to find the clipToGhost node. // global proc string getClipToGhostForScheduler( string $scheduler ) { if ( size( $scheduler ) == 0 ) return ""; string $clips[] = `clipSchedule -q -name $scheduler`; // For each clip get the name of the clipToGhost node connected to it string $clipToGhostNodes[]; for ( $c in $clips ) $clipToGhostNodes = stringArrayCatenate( `listConnections -type clipToGhostData -d 1 -s 0 $c`, $clipToGhostNodes ); // If none of the clips have been connected to the clipToGhost node // yet, the above loop will come up empty. Hence, we // find the clipToGhost node, by seeing looking at the conncetion between the // character and the clipToGhost node string $fromCharacter = clipToGhostFromCharacter( $scheduler ); if ( size($fromCharacter) ) $clipToGhostNodes[ size($clipToGhostNodes) ] = $fromCharacter; // If more than one clipToGhost node is found return an error $clipToGhostNodes = stringArrayRemoveDuplicates( $clipToGhostNodes ); if ( size( $clipToGhostNodes ) > 1 ) error( (uiRes("m_getClipToGhostForScheduler.kErrorMultipleClipToGhostNodes")) ); // Otherwise, return the clipToGhost node return ( size( $clipToGhostNodes ) == 0 ) ? ( "" ) : ( $clipToGhostNodes[0] ); }