// =========================================================================== // 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. // =========================================================================== // // // // // // getNextFreeMultiIndexForSource // // // None. // // // This returns the next multi index that's available // for the given source plug. This is the same // as getNextFreeMultiIndex, but we assume the // attr is a source plug, not destination. This command is useful when // connecting nodes where one wishes to connect to the first available multi // on a node, i.e. the first element that is not already connected. // // // string $attr the name of the multi attribute to get the free index for // int $start the first index to check from ( use zero if last index is not known ) // // // createNode nucleus; // int $index = getNextFreeMultiIndexForSource( "nucleus1.outputObjects", 0 ); // global proc int getNextFreeMultiIndexForSource( string $attr, int $start ) { int $i; for( $i = $start; $i <10000000; $i++) { string $con[] = `connectionInfo -dfs ($attr + "["+$i+"]")`; if( size($con) == 0 ) { return $i; } } return 0; }