// =========================================================================== // 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. // =========================================================================== // // Filter out non-published nodes from black box containers // global proc string[] filterBlackBoxNodes( string $array[], int $inPairs ) // // Description: // Given an array of nodes/plugs, filter out any entry that comes from a // non-published node in a black box container. If $inPairs is false, the last // element is the original node, which we will not filter out. If $inPairs is // true, there is no extra last element, and $array is actually a set of pairs // of entries. We accept/reject each pair bases solely on the second element // in each pair. // // Inputs: // $array : if $inPairs is false, a list of nodes, followed by the // original node; if $inPairs is true, pairs of plugs, which // we accept/reject in pairs, base solely on the second member // of each pair. // $inPairs : true iff we're accepting/rejecting in pairs. // // Return Value: // List of nodes/plugs, or pairs, that pass the black box test. // { // Now filter out non-published nodes from black box containers // string $accepted[]; string $originalNode = ""; string $published[]; string $lastContainer = ""; int $count = size( $array ); if( !$inPairs ){ // The last entry is the original node; grab it, then ignore the extra // entry when doing the black box test. // $originalNode = $array[--$count]; } int $numAccepted = 0; int $i = 0; while( $i < $count ){ if( $inPairs ){ // Testing in pairs, so skip the first entry. // $i++; } string $node = $array[$i++]; if(size($node) && $node != $originalNode){ string $container = `container -q -fc $node`; if( $container != "" ){ if( `getAttr ($container + ".blackBox")` ){ if( $container != $lastContainer ){ // Get the list of published nodes // $lastContainer = $container; clear $published; $published = getPublishedNodes( $container ); } $node = shortNameOf( `plugNode $node` ); if( !stringArrayContains( $node, $published ) ){ // This isn't published, skip it. // continue; } } } } if( $inPairs ){ // Accepting in pairs, get the first entry // $accepted[$numAccepted++] = $array[$i-2]; } $accepted[$numAccepted++] = $array[$i-1]; } return( $accepted ); }