Skip to main content
Inspiring
December 21, 2023
Answered

write expression result to a text box

  • December 21, 2023
  • 4 replies
  • 732 views

Hi

 

I have been doing some very simple expressions like this to generate sin waves and add them. It works fine.

 

 

vel=100;
amp=50
freq1 =1; freq2=0.9; freq3=1.1;
x=time*vel; 

wave1=Math.sin(freq1*time*2*Math.PI);
wave2=Math.sin(freq2*time*2*Math.PI);
wave3=Math.sin(freq3*time*2*Math.PI);
y= amp*(wave1+wave2+wave3)+thisComp.height/2-300;

[x,y];

 However, I would like to be able to have the value for y visible on the stage and updating as the animation goes on. I can't seem to find out how to do this. I guess it is something to do with dynamic text - but I can find how to set the styling but not how to set the actual value of the text.

 

Maybe I am using the wrong search terms.... Could someone please point me in the right direction? 

 

Many thanks

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Dan Ebberts

It may not be what you're looking for here, but I think it's useful to point out that as a debugging tool, you can often just plug an expression that you're working on into the source text property of a text layer and add an extra line to display a variable of interest. So in your case it would be like this to display y:

vel=100;
amp=50
freq1 =1; freq2=0.9; freq3=1.1;
x=time*vel; 

wave1=Math.sin(freq1*time*2*Math.PI);
wave2=Math.sin(freq2*time*2*Math.PI);
wave3=Math.sin(freq3*time*2*Math.PI);
y= amp*(wave1+wave2+wave3)+thisComp.height/2-300;

[x,y];
y

 

 

 

4 replies

Legend
December 21, 2023

 

I hope I have understood the question correctly

 

'Y: '+thisComp.layer("Shape Layer 1").transform.position[1].toFixed(2)

 

maxelcatAuthor
Inspiring
December 21, 2023

Perfect - thank you so much. 

 

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 21, 2023

It may not be what you're looking for here, but I think it's useful to point out that as a debugging tool, you can often just plug an expression that you're working on into the source text property of a text layer and add an extra line to display a variable of interest. So in your case it would be like this to display y:

vel=100;
amp=50
freq1 =1; freq2=0.9; freq3=1.1;
x=time*vel; 

wave1=Math.sin(freq1*time*2*Math.PI);
wave2=Math.sin(freq2*time*2*Math.PI);
wave3=Math.sin(freq3*time*2*Math.PI);
y= amp*(wave1+wave2+wave3)+thisComp.height/2-300;

[x,y];
y