FORUMS: list search recent posts

Closing a Precomp through script

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pritam Bonia
Closing a Precomp through script
on Sep 10, 2015 at 11:28:53 am


I am very new to scripting. Here is what I am trying to do. I have a particular layer in a precomp which has to be replaced with two new layers, which I have been able to do it. But I am unable to close the precomp tab and then close the main project. Below is the code

I am looking for the precomp "Blinking_Boxes" in the project plane and then duplicating/replacing them. Once the task is done, I am trying to close the comp using "app.project.item(i).close()". I can close the main project but when I do that and reopen the project with precomp open.

I want this precomp close as I will be using this script for about 10000 files.

Can anyone please help me with it?

var thirdItem= app.project.item(2)
var fourthItem= app.project.item(3)

for(i=1; i<=app.project.numItems;i++){
var secondItem = app.project.item(i);
if ( == "Blinking_Boxes")
var mySelection = app.project.item(i);

app.project.item(i).layer(2) .replaceSource(thirdItem, true)

app.project.item(i).layer(3) .replaceSource(fourthItem, true)
theLayer = app.project.item(i).layer(2);
theLayer.trackMatteType = TrackMatteType.LUMA

Return to posts index

Walter Soyka
Re: Closing a Precomp through script
on Sep 10, 2015 at 1:23:45 pm

I know you can open a comp in the viewer, but I'm not sure there's a method for closing it.

But we can cheat...

myComp = app.project.item(i); // point to your comp!
myComp.openInViewer(); // make sure the comp is open and active
app.executeCommand(app.findMenuCommandId("Close")); // close the window via the UI

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

Return to posts index

Pritam Bonia
Re: Closing a Precomp through script
on Sep 14, 2015 at 5:46:46 am

Thanks a lot Walter.

That worked.

I failed to mention earlier that I was using CS4, openInViewer() does not work in this version(works only in CS6 I guess). But the closing command did work as it closes whatever comp is open.

Thanks again.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved