Skip to main content
Known Participant
October 9, 2016
Answered

change position of many layers

  • October 9, 2016
  • 1 reply
  • 948 views

Hello,

i tried out a lot and found many things by google, but I can not find any working solution.

I have about 60 layers in my Composition. They all has the same position at this time. The idea is to iterate thru this Items and change them y-position with an offset value.

What I learned so far is, that there is a layer.property("Transform").property("Position"). First I thought this is an Array like [x,y,z], but this seams to be only a ... property.

Now I can check if my layers has the property "Position"...but I already knew this. I found no way to set or even get any values.

I know how to set the position when I create a new Layer, but this seams to be a different thing.

Is there some Possibility to change the Position of an existing Layer by script?

best regards

G

This topic has been closed for replies.
Correct answer UQg

For position or any other property in the layer, you need to use the .setValue(theNewValue) method.


If the property has keyframes, or if you want to add a keyframe, this will throw an error though, so you need to check if the property already has keys, in which case you'll need to use .setValueAtTime(theTime, theNewValue) method.

Example:

layer.property("Transform").property("Position").setValue([x,y,z]);

layer.property("Transform").property("Position").setValueAtTime(0, [x,y,z]);

Check the After Effects Scripting guide (pdf) for more info on this.

Xavier

1 reply

UQg
UQgCorrect answer
Legend
October 9, 2016

For position or any other property in the layer, you need to use the .setValue(theNewValue) method.


If the property has keyframes, or if you want to add a keyframe, this will throw an error though, so you need to check if the property already has keys, in which case you'll need to use .setValueAtTime(theTime, theNewValue) method.

Example:

layer.property("Transform").property("Position").setValue([x,y,z]);

layer.property("Transform").property("Position").setValueAtTime(0, [x,y,z]);

Check the After Effects Scripting guide (pdf) for more info on this.

Xavier

Known Participant
October 9, 2016

Hi Xavier,

"If the property has keyframes ... this will throw an error"

This helped me. Indeed there were some keyframes. Instead of an error the script did nothing, so I thought the setValue method do not match this property. After deleting the keys the script works fine.

Thank you very much!

UQg
Legend
October 9, 2016

Hum yes, reading it again, the second sentence in my answer was badly phrased, but you got it.

Xavier