ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Loop through project panel and select comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hus Yaralioglu
Loop through project panel and select comp
on Jan 6, 2019 at 3:20:23 am

I am new to scripting and I would love some help and advice!

I have a template project that requires me to constantly replace the image in my comp. Using Replace Footage is tedious as I constantly have to navigate folders.

I have created a script that opens a dialog window pointing to a specific folder, and when I import my new image it automatically replaces the one currently in the comp. The problem is the comp index sometimes changes due to the image filenames being different, causing my script to fail.

Please could someone help me change the first line of code so that it loops through the project panel and automatically selects the comp?

// access the comp
var theComp = app.project.item(2);

// get the existing image layer in the comp
var theImageObject = theComp.layers[2];

// bring up folder to import the new image that I'd like to use
var newArtwork = new Folder("C:/Users/PC/Pictures").openDlg("Import File");

// import new image
var newImport = app.project.importFile (new ImportOptions (newArtwork));

// replace the existing image with the new one
theImageObject.replaceSource(newImport, true);


Return to posts index

Dan Ebberts
Re: Loop through project panel and select comp
on Jan 6, 2019 at 6:19:00 am

Do you know the name of the comp? That's probably the easiest way to find a comp by looping through the project items. An alternative would be to use app.project.activeItem if you could assume that the comp is currently the item with focus.

Dan



Return to posts index

Hus Yaralioglu
Re: Loop through project panel and select comp
on Jan 7, 2019 at 7:46:22 am

Well I am also looking to automate the render queue and output filename which will be driven by the comp name, so that won't work as the comp name will change in tandem with each image change.

But I actually thought of a simple workaround! I have placed my comp in a folder called #comp. This ensures the folder is always index 1 and the comp is always index 2, regardless of what the image filename turns out to be, as # always supersedes numbers and characters.


Return to posts index


Dan Ebberts
Re: Loop through project panel and select comp
on Jan 7, 2019 at 2:18:07 pm

Another thing you could do is put an identifying comment in the comp's comment field.

Dan



Return to posts index

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