// =========================================================================== // 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. // =========================================================================== // // // Creation Date: February 10, 1997 // // // Procedure Name: // cycleAnim // // Description: // This is a helper script which will create multiple // copies of the animation on selected objects // // Input Arguments: // float $startTime Time to start copying from // float $endTime Time to start copying to // int $copies Number of copies to make // // Return Value: // None. // global proc cycleAnim (float $startTime, float $endTime, int $copies) { // Constants // string $attributes[3] = {"xValue", "yValue", "zValue"}; // Construct the time range // string $time = string ($startTime) + ":" + string ($endTime); // Find out which objects are selected // string $objects[] = `ls -selection`; int $numObjects = size ($objects); int $numSelected = $numObjects; // For each object // for ($object = 0; $object < $numObjects; $object++) { // Check to see if this "object" is a CV // string $controlPoints[]; catch ($controlPoints = `listAnimatable $objects[$object]`); int $numControlPoints = size ($controlPoints); int $hasControlPoints = 0; for ($controlPoint = 0; ($hasControlPoints == 0) && ($controlPoint < $numControlPoints); $controlPoint++) { string $isControlPoint = match ("controlPoints", $controlPoints[$controlPoint]); if ($isControlPoint == "") { continue; } $hasControlPoints = 1; // It is a controlPoint, so lets copy each animCurve // for ($j = 0; $j < 3; $j++) { string $attribute = ($objects[$object] + "." + $attributes[$j]); string $connectList[]; if (catch ($connectList = `listConnections $attribute`)) { continue; } string $animCurve = ""; for ($k = 0; ($k < size ($connectList)) && ($animCurve == ""); $k++) { string $nodeType = `nodeType $connectList[$k]`; if (substring ($nodeType, 1, 9) == "animCurve") { $animCurve = $connectList[$k]; } } if ($animCurve == "") { continue; } copyKey -time $time $animCurve; for ($i = 0; $i < $copies; $i++) { pasteKey -time $endTime -option connect $animCurve; } } } if ($hasControlPoints == 1) { continue; } // Copy the animation on this object // copyKey -shape true -controlPoints true -time $time $objects[$object]; // And paste the requested number of copies // for ($i = 0; $i < $copies; $i++) { catch (`pasteKey -time $endTime -option connect $objects[$object]`); } } }