# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions substitute the value of a position keyframe with the position value of a null

• # substitute the value of a position keyframe with the position value of a null

Meng Zhiqun updated 2 weeks ago 2 Members · 6 Posts
• ### Jeff Pate

November 16, 2021 at 12:59 am

I have a null with two position key frames. I would like to take the position value of a null with no keyframes to substitute for the second position key frame. I tried using the layer control. Here is the expression I tried.

thisComp.layer(“MOVE_CITIES”).transform.scale.key(2).value;

thisComp.layer(“MOVE_CITIES”).effect(“TRICODE”)(“Layer”).transform.scale;

It ignores the keyframes and makes the position value of the layer I select the only value.

Is there a way to do this?

• ### Meng Zhiqun

November 16, 2021 at 8:37 am

Hi Jeff, I would love to help you out but I don’t really understand your explanation. Are you trying to create an expression on Null1 that moves from its origin to Null2’s position? And I have no idea why are you using scale in your expression.

Perhaps you can try linear(time, 0,2,value,thisComp.layer(“Null2).transform.position); on Null1’s position if you want. If not, could you better explain what are you trying to solve?

• ### Jeff Pate

November 16, 2021 at 4:24 pm

Hey Meng,

hisComp.layer(“masterNull”).transform.position.key(2).value;

thisComp.layer(“masterNull”).effect(“TRICODE”)(“Layer”).transform.position;

I am trying to do both position and scale.

Let’s say I have two keyframes spaced 30 frames apart on the position on a null. The nulls name is “masterNull”

First key frame is 540,540.

Second key frame is 320,320.

I have a second null in the composition name “ARI”

The null labeled “ARI” has the position value of 260,400

I am using the Layer Control effect on the masterNull. The Layer Control effect is labeled “TRICODE”

I want to be able to select “ARI” from the drop down menu of the “TRICODE” on the “masterNull” and have the second key frame change to the position value of “ARI”

In addition I would like to do the same to scale, substituting the scale value of the second key frame in the “masterNull” scale with the scale value of “ARI” using the layer control effect.

the above code substitutes key frame 1 and key frame 2 for the position value of “ARI”

so it would be something like this:

KF1: 540,540 KF2: 320,320

substitute KF2 with: 260,400 from the “ARI” null

I hope this is a better explanation.

Thank you for looking at this.

• ### Meng Zhiqun

November 17, 2021 at 9:22 am

Hey Jeff,

Thanks for your explanation. We can’t change the keyframe value via expression. However, we can get what you want without even including keyframes.

You can try this on your masterNull’s position without keyframes on any layers. “TRICODE” should be a layer control effect applied to the masterNull.

```var target = effect("TRICODE")("Layer");
var lip = thisLayer.inPoint;linear(time, lip, lip+framesToTime(30), value, target.transform.position);```

It should work for scale as well. Just change transform.position to transform.scale. Let me know if it works! 🙂

• ### Jeff Pate

November 17, 2021 at 4:07 pm

Hey Meng,

Thank you! This works! Your Awesome!

• ### Meng Zhiqun

November 18, 2021 at 7:00 am

Glad I could help! Have fun! 🙂

Viewing 1 - 6 of 6 posts