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

Copying position value from one layer to another

New Here ,
Oct 09, 2009 Oct 09, 2009

Hy!

This is Pierluig, from Italy.

I'm a noob in after effect scripting language, but not so new to programming

Anyway, this is the question:

I have a composition with one layer on it. let's say firstlayer.

The layer has two effects on it: topeffect and bottomeffect.

Bottomeffect is an effect called (Transform).

In my script, I want another layer (let's say secondlayer) to set his position from the position of the bottomeffects of the firstlayer.

Problem is, the property "Position" of the secondeffect of the toplayer is calculated trough an expression.

This expressions use a function, and this function is not recognized by the script language

I've tried something like:

  var myArr = ["0","0"];
  myArr = firstlayer.property("Effects").property("(Transform)").property("Position");
  secondo.Position.setValue(time,myArr);

And I got the error: Undefined, is not an object.

I've tried lots, tons of variation, and i've got lots, tons of variation in the error message , but always an error.

So the question is: how can i get my goal?

And my goal is to say, trough a script, after effect to set a property to a layer copying that property from another layer, assuming the layer from wich i copy the property get the property values trough an expression.

Hope I've been clear

Any help will be reallyappreciated, and I'll remember the helpers in my pray

Pierlu

TOPICS
Scripting
3.5K
Translate
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
Adobe Employee ,
Jan 21, 2010 Jan 21, 2010
LATEST

Hi Pierlu,

You can use the valueAtTime() method to retrieve a value pre- or post-expression. Here's some sample code:

var firstLayer = comp.layer("firstlayer");

var secondLayer = comp.layer("secondlayer");

var firstLayerPosition = firstLayer.property("Effects").property("Transform").property("Position").valueAtTime(0, false);

secondLayer.position.setValue(firstLayerPosition);

Hope this helps.

Jeff

Translate
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