// =========================================================================== // 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. // =========================================================================== // // // // // // string sceneTimeWarp( string $action ) // // // Performs a scene timewarp action. // // // string $action The action to perform - one of "add", "select" or "delete" // // // string The name of the timewarp anim curve node // // // string $warp = sceneTimeWarp( "add" ); // // // proc string addTimeWarp() { if ( `connectionInfo -isDestination time1.timewarpIn_Raw` ) { warning( (uiRes("m_sceneTimeWarp.kAlreadyTimeWarp")) ); return ""; } string $warp = `createNode -n timewarp animCurveTT`; connectAttr ( $warp + ".a" ) time1.timewarpIn_Raw; float $start = `playbackOptions -q -minTime`; float $end = `playbackOptions -q -maxTime`; setKeyframe -t $start -v $start -ott clamped $warp; setKeyframe -t $end -v $end -itt clamped $warp; selectKey $warp; setInfinity -pri linear -poi linear; setAttr time1.enableTimewarp 1; return $warp; } proc string selectTimeWarp() { select -clear; string $conns[] = `listConnections -s 1 -d 0 -scn 1 time1.timewarpIn_Raw`; if ( size($conns) == 0 ) { warning( (uiRes("m_sceneTimeWarp.kNoTimeWarpSelect")) ); return ""; } for ( $conn in $conns ) { select -add $conn; } return $conns[0]; } proc string deleteTimeWarp() { string $conns[] = `listConnections -s 1 -d 0 time1.timewarpIn_Raw`; if ( size($conns) == 0 ) { warning( (uiRes("m_sceneTimeWarp.kNoTimeWarpDelete")) ); return ""; } // only actually delete stuff if it looks like something we created in addTimeWarp() // int $didDelete = 0; if ( size($conns) == 1 && `nodeType $conns[0]` == "animCurveTT" ) { string $inputs[] = `listConnections -s 1 -d 0 $conns[0]`; if ( size($inputs) == 0 ) { delete $conns[0]; $didDelete = 1; } } if ( !$didDelete ) { // otherwise just disconnect the inputs // warning( (uiRes("m_sceneTimeWarp.kNotDeleted")) ); string $plugs[] = `listConnections -s 1 -d 0 -p 1 time1.timewarpIn_Raw`; for ( $plug in $plugs ) disconnectAttr $plug time1.timewarpIn_Raw; } setAttr time1.enableTimewarp 0; return $conns[0]; } global proc string sceneTimeWarp( string $action ) { string $result; if ( $action == "add" ) { $result = addTimeWarp(); } else if ( $action == "select" ) { $result = selectTimeWarp(); } else if ( $action == "delete" ) { $result = deleteTimeWarp(); } return $result; }