Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now