• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to change trim path value

Engaged ,
Nov 25, 2023 Nov 25, 2023

Copy link to clipboard

Copied

Hello,

I want to animate a digit with a circle. I want the digit to go from 0 to 20 and simultaneously complete the full trim path circular animation from 0 to 20.

I animated the digit animation with slider control.

I applied trim path to the stroke and also applied angle control to the circle.. and whipped trim path ‘end’ to the angle control so that I can animate it from 0-20 and want circle complete it’s trim path animation from 0-20. (0 first keyframe, last keyframe is 20 in angle control)

but it’s not happening.

At 20 (last key frame) the trim path animation stops.

I understand that trim path value is 100. So to make it a full rotation I must do something so that after effects can make that 100 into ‘20’ .

What is that ‘something’ I can’t figure out.. Google has nothing to offer. Please help. I am so sad.

 

 

trim.giftrim2.gif

Views

362

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 25, 2023 Nov 25, 2023

Add an Expression Control to your text layer. Add an expression to the source text that ties the value of the slider to the text and use toFixes() to limit the number of decimal places. Set some keyframes for the slider with the first zero and the last 20.  Add another expression to the end value that ties the completion to a slider and add linear interpolation to link the start and end values to toe completion of trim paths.

//Text Layer/Source Text
v = effect("Slider Control")("Slider").value;
...

Votes

Translate

Translate
Community Expert ,
Nov 25, 2023 Nov 25, 2023

Copy link to clipboard

Copied

Add an Expression Control to your text layer. Add an expression to the source text that ties the value of the slider to the text and use toFixes() to limit the number of decimal places. Set some keyframes for the slider with the first zero and the last 20.  Add another expression to the end value that ties the completion to a slider and add linear interpolation to link the start and end values to toe completion of trim paths.

//Text Layer/Source Text
v = effect("Slider Control")("Slider").value;
v.toFixed();

//Shape Layer/Trim Paths/End
t = thisComp.layer("Text Layer").thisComp.layer("Text Layer").effect("Slider Control")("Slider");
linear(t, 0, 20, 0, 100)

 

Completion.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

Hi Rick,

 

I have never been so happy. Thank you so much. I am sooo happy. Thank you. been struggling with this for hours...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

I'm glad I could help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2024 Jun 26, 2024

Copy link to clipboard

Copied

Hello Dear Rick,

 

I have another big problem please help me, I have a Decimal Number Counter that is control by an Angle Controller, so I Want to animate a Line with shape layer and trim path, So I connected the end of trim path to the Layer controller, but the problem is here, My number is bigger than 100 and the shape layer animation doesn't work with numbers bigger than 100.

 

I appreciate it if you could help me here's is the Project file link

 

Problem.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 26, 2024 Jun 26, 2024

Copy link to clipboard

Copied

LATEST

It looks like you are converting an angle into dollars and cents and then trying to use that to drive the end value for Shape 1/Trim Path 1/End. 

 

I would have approached the problem by using a Slider Control instead of the rotation control so you could easily see the value you want to display instead of multiplying the rotations by 360 and then adding the angle. This would eliminate the math problem. 

 

Your example also has three keyframes for rotation. You could use a keyframe value to drive a linear interpolation method, but you would need to know the number of the keyframes to retrieve a tMax value.

 

This expression should work if you have 3 keyframes for Angle:

 

 

t = thisComp.layer("<empty text layer>").effect("Counter")("Angle");
tMin = 0;
tMax = t.key(3).value;
linear(t, tMin, tMax, 0, 100);

 

 

Unfortunately, there is no function that will return the value of the last keyframe in the timeline, so you'll have to edit the t.key ().value line to reflect the total number of keyframes for Rotation each time you use this expression (Slider would be simpler).

 

I would have used a different expression for Text/Source Text. If you animate (keyframe) the Trim Paths/End value and add an expression control slider to give you the maximum value you want, this expression will do the trick.

 

 

t = thisComp.layer("Shape Layer 2").content("Shape 1").content("Trim Paths 1").end;
maxVal = effect("Slider Control")("Slider");
val = linear(t, 0, 100, 0, maxVal);
num = "$ "+ val.toFixed() + "";

function addCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
addCommas(num)

 

 

This simplifies the project. You only need one expression for the text layer, an Expression Control Slider Control to set the maximum value, and some keyframes for the Shape Layer/Contents/Shape 1/Trim Path/End property.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines