• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can I import a vector to Adobe After Effects only via scripting

New Here ,
Mar 12, 2019 Mar 12, 2019

Copy link to clipboard

Copied

I'm making an After Effects script that generates simple shapes & animations for kids, and I'm trying to avoid importing vector shapes from Illustrator to After Effects to animate them. And that is working perfectly with the simple shapes such as squares and circles.

Is there any solution for generating complex shapes inside the Extendscript Toolkit, a pure code with no imports or locating some txt file, just by setting the vertices, position and color of the shape and applies it to a new solid as a mask by running the script inside of After Effects?

I'm not talking about images, I need to draw vectors by coding it (same way when you use the pen tool on a solid to draw a mask).

By running the script (File > Scripts > Script Name)

jX6d6.png

You must find this result:

zzYWt.png

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Mar 12, 2019 Mar 12, 2019

This is a quite a complex task you are trying to achieve and there is no, one-click solution.

The hard way is to import the source .AI file into After Effects, convert it to a shape layer with "Create Shapes from Vector Layer" and if everything looks ok with the shape layer, copy every vertex coordinates of every shape in every group to your script and have your script rebuild the whole shape structure.

If I were you, I would start by building a small intermediate tool to show me all the vertices

...

Votes

Translate

Translate
LEGEND ,
Mar 12, 2019 Mar 12, 2019

Copy link to clipboard

Copied

Not really. That's just what the AI conversion does and guess why it took 20 years to appear in AE... Such stuff is far from trivial. You could possibly parse text-based formats like plain XML or SVG, which of course is an option to export from AI, but converting binary data in a script is too far fetched.

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 12, 2019 Mar 12, 2019

Copy link to clipboard

Copied

This is a quite a complex task you are trying to achieve and there is no, one-click solution.

The hard way is to import the source .AI file into After Effects, convert it to a shape layer with "Create Shapes from Vector Layer" and if everything looks ok with the shape layer, copy every vertex coordinates of every shape in every group to your script and have your script rebuild the whole shape structure.

If I were you, I would start by building a small intermediate tool to show me all the vertices of a shape and then copy/embed these vertices inside my script.

Keep in mind that, except for the coordinates of each vertex you will also need the IN and OUT tangent values.

So, if you have a path selected in the timeline (e.g. Shape Layer > Contents > Shape > Path 1 > Path) and run the code below in Extendscript, four prompts will pop-up revealing you all the necessary info to rebuild the selected shape.

var vertex_text = "";

var inTangents_text = "";

var outTangents_text = "";

selectedPath = app.project.activeItem.selectedLayers[0].selectedProperties[0].path.value;

for (var i=0; i < selectedPath.vertices.length; i++) {

    vertex_text = vertex_text + "[" + selectedPath.vertices.toString() + "]";

    inTangents_text = inTangents_text + "[" + selectedPath.inTangents.toString() + "]";

    outTangents_text = outTangents_text + "[" + selectedPath.outTangents.toString() + "]";

    if (i < selectedPath.vertices.length-1) { vertex_text += ","; inTangents_text += ","; outTangents_text += ","; }

} // end for

prompt("The coordinates of the "+i+" vertices of the selected path are: ", vertex_text);

prompt("The inTangents of these vertices are: ", inTangents_text);

prompt("The outTangents of these vertices are: ", outTangents_text);

prompt("The selected path is: ", (selectedPath.closed?"closed":"open"));

You can read about the Shape Object and how to create shapes in Extendscript here: http://docs.aenhancers.com/other/shape/?highlight=tangent

If your shape is quite complex with merged paths etc. (like the reindeer example you mentioned) then you will have to recreate the whole group structure of the shape inside your script. The next step would be to streamline and automate the above process and start building your final script (adding groups, colors, outlines, merging paths).

It is a difficult task, but with a lot of patience it's doable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 01, 2019 Apr 01, 2019

Copy link to clipboard

Copied

Hi AhmadMurad86,

Did TheodorosGR's suggestion help at all?

Thanks,

Rameez

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

LATEST

yes it did

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines