Skip to main content
liors51023776
Participant
December 19, 2016
Question

creating shape from text and get the path

  • December 19, 2016
  • 1 reply
  • 1082 views

Hi everyone!

I am trying to get an answer for this question.

I am working with ExtendScript, and with After Effect.

I have a script like this one:

var comp = app.project.items.addComp('test', 1920, 1080, 1, 30, 25);

var layer = comp.layers.addText('C');

What I am trying to do is to create shape from text by code in extendscript and then to get the path of the shape to array

that will contain the points of the path also in code.

I am sorry but i am beginner.

is there an easy way to do that?

This topic has been closed for replies.

1 reply

Legend
December 20, 2016

Hi liors51023776,

I think you have the wrong forum. This forum is for ExtendScript with FrameMaker, not After Effects.

Russ

Tomas Sinkunas
Legend
December 28, 2016

Hi.

This is rather extensive example, but I think it should get you covered. Cheers.

app.beginUndoGroup("whatever");

var comp = app.project.items.addComp('test', 1920, 1080, 1, 30, 25);

  comp.openInViewer();

var textLayer = comp.layers.addText('CA');

  textLayer.selected = true; // Make sure Text Layer is selected

  app.executeCommand(3781); // Execute command "Create Shapes from Text"

  textLayer.remove() // Removes old text layer

var shapeLayer = comp.selectedLayers[0]; // Store shape layer to variable

var allPaths = getAllPaths(shapeLayer, []); // Collect all Path properties to array;

for (var i = 0, il = allPaths.length; i < il; i ++) {

  var currentPathProperty = allPaths;

  var pathValue = currentPathProperty.value;

  var vertices = pathValue.vertices; // Returns Vertives of the shape

  var inTangents = pathValue.inTangents; // Returns inTangens of the shape

  var outTangents = pathValue.inTangents; // Returns outTangents of the shape

}

app.endUndoGroup();

function getAllPaths(currentProperty, propsArray){

  for (var i = 1, il = currentProperty.numProperties; i <= il; i++) {

  if (currentProperty.property(i).matchName === "ADBE Vector Shape")

  propsArray.push(currentProperty.property(i));

  getAllPaths(currentProperty.property(i), propsArray);

  }

  return propsArray

}