/* File: ..//src//afterEffects//om_inout.jsx Date: Sat Dec 27 15:17:32 MYT 2008 Author: David Van Brink This script is part of the omino adobe script suite. The latest version can be found at http://omino.com/pixelblog/. I write these because I like to. Please enjoy as you see fit. Questions to poly@omino.com, subject line should start with "plugins" so my spam filter lets it in. This file has been preprocessed to be standalone. I develop them against some reusable libraries -- such as for dialog layout -- but for distribution it's nicer to have just one file. dvb 2007. */ /* Description: This After Effects script sets the in- our out-point of the selected layers to the current time. It can be run as a palette, or installed as a dockable item in ScriptUI Panels folder. :: */ { function main(thisObj) { // thisObj is either a palette from AE (the host), or nothing. // if nothing, be a dialog. thisObj = (thisObj instanceof Panel) ? thisObj : new Window("palette","om_inout",undefined,{resizeable:true}); var note = thisObj.add('statictext',undefined,"Set the in- or out-point\nof the selected layer(s).",{multiline:true}); var bIn = thisObj.add('button', [15,15,70,35], '>in'); var bOut = thisObj.add('button', [75,15,130,35], 'out<'); bIn.onClick = setInPoint; bOut.onClick = setOutPoint; thisObj.layout.layout(true); if(thisObj instanceof Window) thisObj.show(); } // set the in point to the current time... unless doOutPoint, in which case... function setInOutPoints(doOutPoint) { var selectedLayers = new Array(); myComp = app.project.activeItem; if(myComp instanceof CompItem) selectedLayers = myComp.selectedLayers; else selectedLayers = new Array(); // either no comp was selected, or no layers in it were.s if(selectedLayers.length == 0) { alert("om_inout\nPlease select one or more\nlayers in a composition."); return; } app.beginUndoGroup("om_inout: set " + (doOutPoint ? "out" : "in") + " points"); for(var ix in selectedLayers) { var layer = selectedLayers[ix]; if(doOutPoint) layer.outPoint = myComp.time; else { // bug? setting in seems to corrupt out. save and fix. var outPoint = layer.outPoint; layer.inPoint = myComp.time; layer.outPoint = outPoint;s } } app.endUndoGroup(); } function setInPoint() { var layers = setInOutPoints(false); } function setOutPoint() { var layers = setInOutPoints(true); } main(this); }