Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript

  • Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript

    Posted by Dennis Van zwet on September 5, 2019 at 7:51 am

    Hi all,

    I have a problem getting started with a script that allow me to import a illustrator file (with dialog import window, command-i), place it on the active composition as a new layer, convert it to a shapelayer, add layer style (stroke, stroke color, stroke size, stroke position) and add trim path keyframes.

    This is my starting code:

    var myComp = app.project.activeItem; //active comp
    var myFile = app.project.importFileWithDialog(); //import illustrator file
    var myLayer = myComp.layers.add(myFile); //add to active comp as new layer

    I get a error “After Effects error: Unable to call “add” because of parameter 1. Array is not of the correct type.”

    Hope someone can get me started, what am I doing wrong?

    Greetz,
    Dennis.

    Dan Ebberts replied 6 years, 8 months ago 3 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    September 5, 2019 at 1:30 pm

    You’re close. importFileWithDialog() returns an array of items. Try changing the last line to:

    var myLayer = myComp.layers.add(myFile[0]);

    Dan

  • Dennis Van zwet

    September 5, 2019 at 2:41 pm

    Yeahhhh, that worked, thank you Dan.
    I think I’m starting to like learning Extendscript.

  • Dennis Van zwet

    September 5, 2019 at 7:02 pm

    Sorry for bothering you guys again, I have looked at al possible threads, but found noting.

    I’m having a problem with creating a shape layer from an .ai file.

    On a selected .ai layer I’m using:

    app.executeCommand(3973);

    But nothing happens, is this is the correct way to “Create Shapes from Vector Layer”?


    var myComp = app.project.item(1); //active comp
    var myFile = app.project.importFileWithDialog(); //import illustrator file
    var myLayer = myComp.layers.add(myFile[0]); //add to active comp as new layer
    myComp.layer(1).selected = true;
    //alert( app.findMenuCommandId("Create Shapes from Vector Layer"));
    app.executeCommand(3973);

  • Rainier Raydán

    September 5, 2019 at 8:49 pm

    Hi!

    Try this

    var myComp = app.project.item(1); //active comp
    var myFile = app.project.importFileWithDialog(); //import illustrator file
    var myLayer = myComp.layers.add(myFile[0]); //add to active comp as new layer
    myLayer.selected = true;

    app.executeCommand(3973);

  • Dennis Van zwet

    September 6, 2019 at 6:00 am

    Hi Rainier,

    Thank you for your reply. Tried your code, the layer in my comp is selected but converting to a shape layer doesn’t work, I’m not sure why?

    Greetz.

  • Dan Ebberts

    September 6, 2019 at 3:01 pm

    Try it this way:

    var myComp = app.project.item(1); //active comp
    var myFile = app.project.importFileWithDialog(); //import illustrator file
    var myLayer = myComp.layers.add(myFile[0]); //add to active comp as new layer
    myComp.openInViewer();
    myComp.layer(1).selected = true;
    app.executeCommand(app.findMenuCommandId(“Create Shapes from Vector Layer”));

    Dan

  • Dennis Van zwet

    September 6, 2019 at 3:21 pm

    Thank you ones again Dan, my new hero.

    As I understand the comp was not active in the viewer?

    https://docs.aenhancers.com/items/footageitem/#footageitem-openinviewer

  • Dan Ebberts

    September 6, 2019 at 3:31 pm

    My guess is that importing the file takes focus away from the comp panel and gives it to the project panel.

    Dan

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