Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Import a file + a couple more steps script

  • Import a file + a couple more steps script

  • Deanna Keogh

    January 29, 2020 at 7:50 am


    Just after some help in scripting some automated workflow in after effects. (I’ve downloaded kbar and am making scriptlet buttons)
    I’m learning how to do broader after effects scripting slowly but I don’t really understand as much as I’d like.

    Im after a script that:
    1. Imports 2 files
    2. Puts the files in the current selected comp
    3. Make them a guide layer
    4. Lock them both

    I’ve currently only got step one down, which is simple stuff, and that was after a lot of googling.
    I know I need to add some variables and something like var myComp = app.project.activeItem; etc.
    Im just not sure of the order and finer details…
    Any help would be greatly appreciated 🙂

    newFootageItem = app.project.importFile(new ImportOptions(new File("filepath/FILE1.png")));
    newFootageItem = app.project.importFile(new ImportOptions(new File("filepath/FILE2.png")));

  • Andrei Popa

    January 29, 2020 at 8:17 am

    Something like this maybe

    newFootageItem = app.project.importFile(new ImportOptions(File.openDialog()));
    newFootageItem1 = app.project.importFile(new ImportOptions(File.openDialog()));
    myCrtComp = app.project.activeItem;
    var layer1 = myCrtComp.layers.add(newFootageItem);
    var layer2 = myCrtComp.layers.add(newFootageItem1);
    layer1.guideLayer = true;
    layer1.locked = true;
    layer2.guideLayer = true;
    layer2.locked = true;

    My Envato portfolio.

  • Deanna Keogh

    January 30, 2020 at 3:30 am

    Thank you so much! That worked perfectly!

    The only issue I’ve noticed is that when I run the script, it imports, sets to guide layer and locks, but then if I delete them out of the project and try to run the script again it won’t import them into the same comps as before and I get an error. I have to create a new comp and then I can run the script again, then this works. Do you have any idea why this is occurring?

    Thanks so much for your help!

  • Tomas BumbuleviÄŤius

    January 30, 2020 at 3:37 pm

    Deanna, for this script to work you need to have composition in After Effects opened, and active, before running a script.

    Alternatively, if this does not help, please share error you are getting and someone will be definitely able to help you out.


    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

  • Deanna Keogh

    February 5, 2020 at 1:08 am

    You are completely right Tomas, thank you. I thought it would work if I had it selected in the projects panel but it need to be active in the comp panel. Silly me haha

    Thanks for your help!

Viewing 1 - 5 of 5 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy