ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

is it possible in a script to target a specific comp layer without having that comp selected in the project window ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dirk de Jong
is it possible in a script to target a specific comp layer without having that comp selected in the project window ?
on Oct 15, 2017 at 6:43:17 pm
Last Edited By Dirk de Jong on Oct 15, 2017 at 6:43:54 pm

I'm new to AE scripting, but I'm thinking the answer to my question in the subject line is "no." and seeking confirmation or denial...

It seems like there is no obvious way (in a script) to directly target the layer that is selected in the timeline tab that currently has focus (without requiring a user to select the comp in the project window)... like you can when applying an effect from the Effect menu (but I could be missing something). It seems like there is an activeViewer attribute but no activeTimeline attribute (which is perhaps part of what it would require)... If there is a way I suspect people on this forum would know. Thanks.


Return to posts index

Xavier Gomez
Re: is it possible in a script to target a specific comp layer without having that comp selected in the project window ?
on Oct 15, 2017 at 9:57:26 pm

The After Effects scripting guide has a very loosy description of app.project.activeItem.
If you follow it, you might think it is only determined by the panel selection, but it's not.

It seems to be determined in this order:

if the Project Panel is active, then it is the unique selected item in that Panel, or null.
if the Project Panel is not active, then it is the front comp in the Timeline Panel if any, or null again.

(paradoxally, viewers dont play a role, you can have all viewers closed and no project selection, and still have a comp "active": the one in front in the timeline panel).

So you can do this:

var X = app.project.activeItem;
if (X instanceof CompItem && !X.selected){
// X is the comp in front in the timeline
}
else{
// stuck
};

If you have CS6 or later, you can do this prior to querying activeItem:

if (app.activeViewer!=null && (app.activeViewer.type==ViewerType.VIEWER_COMPOSITION)){
app.activeViewer.setActive();
// at this stage, app.project.activeItem is necessarily the front comp in the timeline panel
var comp = app.project.activeItem;
var layers = comp.selectedLayers;
}
else{
// ask to activate a comp
};


Xavier


Return to posts index

Dirk de Jong
Re: is it possible in a script to target a specific comp layer without having that comp selected in the project window ?
on Oct 16, 2017 at 12:17:51 pm

Thanks very much for the quick reply and useful suggestions. I'll give these things a try.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]