// =========================================================================== // 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: Oct, 2000 // // Procedure Name: // toggleClipOffset // // Description: // Make clip absolute or relative // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // // $args // Version 1 // [0] $name : name of the clip window // [1] $op : type of enable operation: // 0 = make relative // 1 = make absolute // 2 = toggle state // Version 2 // [0] $op : type of enable operation: // 0 = make relative // 1 = make absolute // 2 = toggle state // [1] $selectedClips : true/false, whether to also toggle selected clips // [2] $clip : single clip to operate upon, if not empty // // global proc toggleClipOffset( string $version, string $args[] ) { int $versionNum = $version; int $op; int $workOnSelection = 1; string $clip; if ($versionNum == 1) { $op = $args[1]; } else { $op = $args[0]; $workOnSelection = $args[1]; if (size($args) > 2) { $clip = $args[2]; } } string $selClips[]; if ($workOnSelection) { $selClips = getSelectedClips("noOptions"); } if (size($clip) > 0) { if (AWNumberOfOccurrencesInStringArray($clip,$selClips) == 0) { $selClips[size($selClips)] = $clip; } } int $nclips = size($selClips); if ($nclips == 0) { if ($op == 0) { error((uiRes("m_toggleClipOffset.kSelectClipRelative"))); } else if ($op == 1) { error((uiRes("m_toggleClipOffset.kSelectClipAbsolute"))); } else { error((uiRes("m_toggleClipOffset.kMustSelectAClip"))); } } else { for ($clip in $selClips) { string $cmdString; string $sched = getClipScheduler($clip); int $index = getClipIndex($clip,$sched); $cmdString = ("clipSchedule -ci "+$index+" "); if ($op == 0) { $cmdString += ("-allRelative "); } else if ($op == 1) { $cmdString += ("-allAbsolute "); } else { string $absClip = `clipSchedule -ci $index -q -absolute $sched`; if ($absClip) { $cmdString += ("-allRelative "); } else { $cmdString += ("-allAbsolute "); } } $cmdString += (" "+$sched); evalEcho($cmdString); } } string $printMsg; if ($op == 0 || $op == 1) { string $operName = ($op == 0) ? (uiRes("m_toggleClipOffset.kRelative")): (uiRes("m_toggleClipOffset.kAbsolute")); $printMsg = (uiRes("m_toggleClipOffset.kSetClips")); print(`format -s (size($selClips)) -s $operName $printMsg`); } else { $printMsg = (uiRes("m_toggleClipOffset.kToggleRelativeOn")); print(`format -s (size($selClips)) $printMsg`); } }