Skip to main content
StefanStehlik
Inspiring
November 1, 2022
Answered

Path expression - auto adjust

  • November 1, 2022
  • 3 replies
  • 567 views

Hello, Is there a way to create a shape with a path from top left corner to the top right corner, with an anchor point in center of composition? It would be nice if there is a way to set the expression to auto-adjust the position and length of the path when changing composition size.

This topic has been closed for replies.
Correct answer Dan Ebberts

Or, just click in an empty comp with the pen tool to create a shape layer and add this expression for the path:

points = [fromComp([0,0]),fromComp([thisComp.width,0])];
createPath(points,[],[],false)

 

3 replies

Community Expert
November 1, 2022

My approach to that problem would be to create a simple two-point path, open the Create Nulls from Paths.jsx script from the Window menu, select the path, choose Points Follow nulls, then use this expression for the first null's position:

 

[0, 0]

 

 And this expression for the second null's position;

 

[thisComp.width, 0]

 

 No matter the comp size, the nulls would be in the upper right corner and the upper left corner of the composition, and the path would follow.

 

If you want something more than that, you have to let us know.

 

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 1, 2022

Or, just click in an empty comp with the pen tool to create a shape layer and add this expression for the path:

points = [fromComp([0,0]),fromComp([thisComp.width,0])];
createPath(points,[],[],false)

 

Community Expert
November 1, 2022

Dan, your are the man....

Mylenium
Legend
November 1, 2022

Then explain what isn't working rather than just stating that it isn't. Nobody can work on thin air. Provide your code and screenshots.

 

Mylenium 

Mylenium
Legend
November 1, 2022

I'm not clear what you mean. The createPath() expressions don't require any magic beyond doing the calculations for the points. You would simply use this comp.widh and so on and do the math.

 

Mylenium 

StefanStehlik
Inspiring
November 1, 2022

It's not that simple... I have a problem with the calculation.