// =========================================================================== // 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. // =========================================================================== ////////////////////////////////////////////////////////////////////////////////////////// // // updateLayerContainer() // - This method packages the layer node, blendnodes and animcurves associated with a layer // into appropriate containers. The blendnodes and animcurves will each have their own container, // and these are thrown into a bigger container that also contains the layer node. global proc updateLayerContainer(string $layer) { // Let's try to find the container attach to this layer string $container; string $blendNodeContainer; //The root layer has now been tagged as a default node. // Default nodes cannot be added to assets, so we'll bail here. if($layer == `animLayer -q -root`) return; $container = `container -q -findContainer $layer`; if(size($container) <= 0) { // No container fopund, create a new one $container = `container -name ($layer+"_Asset") -addNode $layer`; } string $blendNodes[] = `animLayer -q -blendNodes $layer`; int $createdBlendNodeContainer = 0; if(size($blendNodes) > 0) { string $blendNode = $blendNodes[0]; $blendNodeContainer = `container -q -findContainer $blendNode`; if(size($blendNodeContainer) <= 0) { // No container found, create a new one $blendNodeContainer = `container -name ($layer+"_BlendNodes") -addNode $blendNode`; $createdBlendNodeContainer = 1; } if($createdBlendNodeContainer) { container -edit -addNode $blendNodeContainer $container; } } for($blendNode in $blendNodes) { string $currBlendNodeContainer = `container -q -findContainer $blendNode`; if($currBlendNodeContainer != $blendNodeContainer) { container -edit -addNode $blendNode $blendNodeContainer; } } string $curvesContainer; string $allCurves[] = `animLayer -q -animCurves $layer`; int $createdCurvesContainer = 0; if(size($allCurves) > 0) { for($curve in $allCurves) { if($curvesContainer == "") { $curvesContainer = `container -q -findContainer $curve`; if(size($curvesContainer) > 0) { break; } } } for($curve in $allCurves) { if(size($curvesContainer) <= 0) { $curvesContainer = `container -name ($layer+"_Curves") -addNode $curve`; $createdCurvesContainer = 1; } string $currCurvesContainer = `container -q -findContainer $curve`; if($currCurvesContainer != $curvesContainer) { container -edit -addNode $curve $curvesContainer; } } if($createdCurvesContainer) { container -edit -addNode $curvesContainer $container; } } string $baseCurvesContainer = "BaseAnimation_Layered_Curves"; string $baseCurves[] = `animLayer -q -baseAnimCurves $layer`; if(size($baseCurves) > 0) { int $foundBaseAnimationContainer = 0; string $result[] = `ls BaseAnimation_Layered_Curves`; if(size($result) > 0) { if(`nodeType BaseAnimation_Layered_Curves` == "container") { $foundBaseAnimationContainer = 1; } } for($curve in $baseCurves) { if(!$foundBaseAnimationContainer) { string $currContainer = `container -q -findContainer $curve`; if($currContainer != "") { container -edit -removeNode $curve $currContainer; } $baseCurvesContainer = `container -name "BaseAnimation_Layered_Curves" -addNode $curve`; $foundBaseAnimationContainer = 1; } string $currCurvesContainer = `container -q -findContainer $curve`; if($currCurvesContainer != $baseCurvesContainer) { if($currCurvesContainer != "") { container -edit -removeNode $curve $currCurvesContainer; } container -edit -addNode $curve $baseCurvesContainer; } } } }