• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting Layer Duration in Photoshop Timeline

Participant ,
Sep 28, 2019 Sep 28, 2019

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:

  • I have looked for scripting information about the Timeline in Photoshop Scripting Basics and Adobe Photoshop CC JavaScript Reference but found nothing.
  • I have also looked for Timeline objects in the Extendscript Toolkit Data Browser but found nothing.
  • I've looked at the ScriptingListenerJS.log and found an executeAction call for changing the Out Time, but nothing about the layer's duration:
    // =======================================================
    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!

TOPICS
Actions and scripting

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Sep 29, 2019 Sep 29, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 29, 2019 Sep 29, 2019

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."

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2019 Sep 29, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 10, 2020 Jan 10, 2020

Copy link to clipboard

Copied

LATEST

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);
})();

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines