61 lines
1.5 KiB
React
61 lines
1.5 KiB
React
/**
|
|||
|
|
* @description a headless script to do something cool in AE
|
||
|
|
* @name km-trim-selected-comps-work_area
|
||
|
|
* @author Kyle Harter <kylenmotion@gmail.com>
|
||
|
|
* @version 1.0.0
|
||
|
|
*
|
||
|
|
* @license This script is provided "as is," without warranty of any kind, expressed or implied. In
|
||
|
|
* no event shall the author be held liable for any damages arising in any way from the use of this
|
||
|
|
* script.
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
|
||
|
|
(function () {
|
||
|
|
//@include "../library/km_helperFunctions.jsx";
|
||
|
|
//@include "../library/km_scriptUI_functions.jsx";
|
||
|
|
//@include "../library/km_utilityFunctions.jsx";
|
||
|
|
//@include "../library/km_textAnimators.jsx";
|
||
|
|
//@include "../library/km_systemFunctions.jsx";
|
||
|
|
try {
|
||
|
|
app.beginUndoGroup("what does this script do?");
|
||
|
|
var km = kmFunction;
|
||
|
|
var kmScript = kmScriptUI;
|
||
|
|
var kmUtils = kmUtilityFunctions;
|
||
|
|
var kmTextAnims = KMTextAnimatorsLib;
|
||
|
|
var kmSystems = kmSystemsLib;
|
||
|
|
|
||
|
|
var comps = km.getSelectedComps(km.getProj()).comps;
|
||
|
|
|
||
|
|
var trimmedComps = trimCompsWorkArea(comps);
|
||
|
|
|
||
|
|
alert('Comps Trimmed: ' + trimmedComps)
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
alert(
|
||
|
|
"An error occured on line: " +
|
||
|
|
error.line +
|
||
|
|
"\nError message: " +
|
||
|
|
error.message,
|
||
|
|
);
|
||
|
|
} finally {
|
||
|
|
// this always runs no matter what
|
||
|
|
app.endUndoGroup();
|
||
|
|
}
|
||
|
|
|
||
|
|
function trimCompsWorkArea(comps) {
|
||
|
|
var compsTrimmed = 0
|
||
|
|
for(var i = 0; i < comps.length; i++){
|
||
|
|
var comp = comps[i];
|
||
|
|
comp.openInViewer();
|
||
|
|
app.executeCommand(2360);
|
||
|
|
comp.time = comp.duration/2;
|
||
|
|
compsTrimmed++
|
||
|
|
}
|
||
|
|
|
||
|
|
return compsTrimmed
|
||
|
|
}
|
||
|
|
})();
|