ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Script work with timeline

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vasyl Iskovych
Script work with timeline
on Mar 31, 2019 at 1:30:24 pm

Hello.
I want the script to add layers to the open composition.
I want to make the script work only if the "Timeline" panel is highlighted.
I add layers like this:
app.project.activeItem.layers.addNull();
But if the composition is selected in the "Project" panel, then the layer will be created in it.
It can be done so that in this case alert is displayed "select the timeline"; ?


Return to posts index

Tomas Bumbulevičius
Re: Script work with timeline
on Mar 31, 2019 at 6:52:54 pm

Hello Vasyl,

is the composition selected in the project is the same as the activeItem?

You can 'force' AE to make composition active, by calling:

curComp.openInViewer();

where 'curComp' should be comp item. Accordingly, you could grab selection from the project panel and use it for activating the viewer.

curComp = app.project.selection[0];

where selection[0] would be selected item in the project panel, assuming its composition.

Whole scenario below, assuming that your selected comp in the project panel actually matches the one which you want to add item to. If it does not necessarily matches - then slight adjustments could be made.

var curComp = app.project.selection[0];
curComp.openInViewer();
curComp.layers.addNull();


Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index

Vasyl Iskovych
Re: Script work with timeline
on Apr 1, 2019 at 7:46:34 am

Thanks for the answer.
But this is not what I need.
I need the script to work only in the composition that is open in the "Viewer".
And if the selected other composition, then show the "alert"


Return to posts index


Tomas Bumbulevičius
Re: Script work with timeline
on Apr 1, 2019 at 4:03:49 pm

Ok, there can be two scenarios per your current explanation:
1. Script works in an active and opened composition.
2. Script does not work when other composition is selected in project panel.

Now the main question is about the second point - selected WHERE?

But if the composition is selected in the "Project" panel, then the layer will be created in it.
It can be done so that in this case alert is displayed "select the timeline"; ?


This message above from the original post overrides requirements and its not clear. Please clarify this further. Thanks!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index

Vasyl Iskovych
Re: Script work with timeline
on Apr 1, 2019 at 4:41:11 pm

It is necessary that the layer can be created only in the composition that is open on the "timeline".


Return to posts index

Tomas Bumbulevičius
Re: Script work with timeline
on Apr 1, 2019 at 4:46:22 pm

Composition can be opened in the timeline, visible, but not active (meaning, it is not highlighted, and not accessible via 'activeItem').

With that said:

if (app.project.activeItem != null){
//Do any actions you want in an active comp
}else{
alert("Composition is not active in the project.")
}


Find out more:
After Effects Tutorials: motion design, expressions, scripting.


Return to posts index

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