// =========================================================================== // 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: // This script creates a weight curve for cache clip. // global proc doCreateCacheClipWeightCurve (string $clips[]) { int $nClips = size($clips); if ($nClips == 0) { return; } int $ii = 0; for ($ii = 0; $ii < $nClips; $ii++) { string $clip = $clips[$ii]; string $cacheBlendNodeList[] = getSelectedCacheBlends($clip); if(size($cacheBlendNodeList) > 0) { //get weight curve of cache file node int $multiIndex = `cacheFileCombine -cc $clip -q -cacheIndex $cacheBlendNodeList[0]`; if ( $multiIndex != -1 ) { string $srcPlug = $cacheBlendNodeList[0] + ".cacheData[" + $multiIndex + "].weight"; if (`objExists $srcPlug`) { string $weightC[] = `listConnections -source true -destination false $srcPlug`; if(size($weightC) > 0) { // Something is already connected, so do nothing. // string $warnMsg = (uiRes("m_doCreateCacheClipWeightCurve.kSrcPlug")); $warnMsg = `format -s $srcPlug $warnMsg`; warning($warnMsg); continue; } } float $startTime = `getAttr ($clip + ".startFrame")`; setKeyframe -at ("cacheData[" + $multiIndex + "].weight") -t $startTime -v 1.0 $cacheBlendNodeList[0]; float $sourceStartTime = `getAttr ($clip + ".sourceStart")`; float $sourceEndTime = `getAttr ($clip + ".sourceEnd")`; float $endTime = ($sourceEndTime - $sourceStartTime) * `getAttr ($clip + ".scale")`; setKeyframe -at ("cacheData[" + $multiIndex +"].weight") -t ($startTime + $endTime) -v 1.0 $cacheBlendNodeList[0]; } } else { string $warnMsg = (uiRes("m_doCreateCacheClipWeightCurve.kNoCacheBlend")); $warnMsg = `format -s $clip $warnMsg`; warning($warnMsg); } } }