ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dennis van Zwet
Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 5, 2019 at 7:51:03 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.


Return to posts index

Dan Ebberts
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 5, 2019 at 1:30:40 pm

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

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


Dan



Return to posts index

Dennis van Zwet
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 5, 2019 at 2:41:18 pm

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


Return to posts index


Dennis van Zwet
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 5, 2019 at 7:02:56 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);


Return to posts index

Rainier Raydán
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 5, 2019 at 8:49:08 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);


Return to posts index

Dennis van Zwet
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 6, 2019 at 6:00:52 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.


Return to posts index


Dan Ebberts
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 6, 2019 at 3:01:13 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



Return to posts index

Dennis van Zwet
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 6, 2019 at 3:21:24 pm

Thank you ones again Dan, my new hero.

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

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


Return to posts index

Dan Ebberts
Re: Import Adobe Illustrator .ai file and place it on a active comp as a layer with Extendscript
on Sep 6, 2019 at 3:31:34 pm

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

Dan



Return to posts index

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