Copy link to clipboard
Copied
Hello,
I'm trying to write a script that changes the duration of a layer in the Photoshop timeline.
I haven't been able to find ANY information about the Timeline:
// ======================================================= var idmoveOutTime = stringIDToTypeID( "moveOutTime" ); var desc206 = new ActionDescriptor(); var idtimeOffset = stringIDToTypeID( "timeOffset" ); var desc207 = new ActionDescriptor(); var idseconds = stringIDToTypeID( "seconds" ); desc207.putInteger( idseconds, -4 ); var idframe = stringIDToTypeID( "frame" ); desc207.putInteger( idframe, -23 ); var idframeRate = stringIDToTypeID( "frameRate" ); desc207.putDouble( idframeRate, 24.000000 ); var idtimecode = stringIDToTypeID( "timecode" ); desc206.putObject( idtimeOffset, idtimecode, desc207 ); executeAction( idmoveOutTime, desc206, DialogModes.NO );
I'd need to know a layer's duration in order to know how much to reduce the OutTime in the Timeline.
Can anyone help me find documentation on how to script for the Photoshop Timeline?
Thank you!
Copy link to clipboard
Copied
I don't think they are officially documented anywhere "for reasons". The UI callbacks are probably everything you are ever going to get from this self-contained bubble.
Mylenium
Copy link to clipboard
Copied
Someone who know how to modify AM code might be able to do it. I tried working with the timeline once and asked an Adobe engineer about it, and all he replied as, "It's black magic."
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I wanted to decrease the outTime of all the layers to some value. What I ended up is decreasing the layer OutTime to zero and then increasing it back to where I want it to be. It appeared to work as an action. So I made the script.
Here is the final script to make all layers in th timeline be 1 second long:
var doc = app.activeDocument;
function ExecuteOnAllSets(item) {
ExecuteOnAllLayersInSet(item, Action);
var i = 0;
while (i < item.layerSets.length) {
ExecuteOnAllSets(item.layerSets[i]);
i++;
}
}
function ExecuteOnAllLayersInSet(set, f) {
var i = 0;
while (i < set.artLayers.length) {
SelectLayer(set.artLayers[i]);
f();
i++;
}
}
function Action() {
ChangeLayerTLLength(-90, 0);
ChangeLayerTLLength(1, 0);
}
function ChangeLayerTLLength(seconds, frames) {
var idmoveOutTime = stringIDToTypeID( "moveOutTime" );
var desc8 = new ActionDescriptor();
var idtimeOffset = stringIDToTypeID( "timeOffset" );
var desc9 = new ActionDescriptor();
var idseconds = stringIDToTypeID( "seconds" );
desc9.putInteger( idseconds, seconds );
var idframe = stringIDToTypeID( "frame" );
desc9.putInteger( idframe, frames );
var idframeRate = stringIDToTypeID( "frameRate" );
desc9.putDouble( idframeRate, 30.000000 );
var idtimecode = stringIDToTypeID( "timecode" );
desc8.putObject( idtimeOffset, idtimecode, desc9 );
executeAction( idmoveOutTime, desc8, DialogModes.NO );
}
function SelectLayer(layer) {
doc.activeLayer = layer;
}
(function main() {
ExecuteOnAllSets(doc);
})();