Skip to main content
Participating Frequently
February 7, 2022
Question

Shape to follow a path that was created in an expression from csv data

  • February 7, 2022
  • 2 replies
  • 651 views

There are hundreds of examples of how to make a shape follow a path, all of them involve copying the actual path into the shape's position and you get the results. This does not work when your path come from an expression, in which the path was created with createPath previously reading data points from a csv file.

 

Other method, which looks cool, is when using Text, you use Path Options, them from the drop down you pick a mask where you already have your path in code, then I can play with Last Margin/First Margin properties to get the text moving over time....this works except that I don't want it for Text. And I can't find a way to have a Path Options in a shape.

 

I also tried this. Have a Shape Layer, with an Ellipse (the moving object), add a path, then add the expression and it seems I have a path for my moving object. But then how do achieve moving the object overtime?  The purpose of my composition is to have the object to move according to the time in the CSV data.

 

The only way I have accomplished this, is to have the Transform.Position of my shapelayer with expression to read again from the CSV data, but in this method the object does not move smoothly.The shape does not move as smoothly as the the text following the path using Path options.

 

So, what I'm looking is how do I make a shape to follow a path, when path has been created with an expression.

Thanks in advance

 

 

This topic has been closed for replies.

2 replies

Mylenium
Legend
February 7, 2022

30 to 60 minutes of data? How will that wever work? You will be easily exhausting all sorts of limits not just in AE, but in JavaScript in general. Your approach makes zero sense, given that a path in AE can only have so many points, anyway. As Paul already said, if at all, the data can only be processed on a frame-by-frame basis directly in the position. Whatever smoothing and interpolation you need will have to be created by writing a suitable routine, but since you haven't really explained the purpose of your whole undertaking nor provided any examples of the data nobody can even begin to think about specific code bits.

 

Mylenium

CesarRVGAuthor
Participating Frequently
February 7, 2022

Thanks for your answer. Let me explain you a little more.
What I'm doing is a sort of a line chart race animation.

The data comes from a real-time log from a machine which could have a resolution of up to 10th of a second.
So that a 5 minute log, has about 3,000 rows of data. Anyway, I'm not reading every all the 3,000 dots but just 300 as I'll explain below. Then the requirement is to visualize the changes as happened in real time, so for a 5 minute log I will have to create 5 minute video. For 90 minute log, I will have a 90 minute video and so on, that's the requirement. The data changes should be visualized in a line chart that it's displayed in the start of the video, and then a red dot indicator will travel through the path in the video as it happened in real time.

Please note that I already have a partial working solution for this is what I did:
I set the CSV file in the project, as footage, but not as a layer.
I created a path in a shape layer by reading the CSV file in a loop, and using createPath function. The path contains peaks and valleys from a range from 100 to 200. I used linear to interpolate data to a region of the screen. For the creation of the path, I just take 1 value out of 10 in the file, which is a second, so, for my 5 minute video, I have a 300 points path. I have all the maths to make it fit the screen proportionally with margins, etc. The line chart looks smooth despite I'm discarding 90% of the data.

Now I have another Shape layer with an red ellipsis to use as an indicator. In the transform properties I setup the "X position" property by just calculating the position according to the video time, I don't even have to read the CSV file for the X.
Now, for the "Y position" property, I read the CSV file again taking in consideration the time and the fact that I'm just reading 1 value per second.
This works somehow, but not exactly: it looks jumpy, or wiggly, because it jumps from second to second. I want it to go smoothly from one point to another, but I can't use "Easy Ease" because I don't even have time frames.

So I came here for expert advise of a better solution if that exists, like using the preexising created path and feed that path to the red dot to travel across, or somehow make smooth transitions from point to point.

Thanks again for your time.

Roland Kahlenberg
Legend
February 8, 2022

This sounds interesting but I'm not able to visualize the intent nor have a good appreciation of what your source data look like. If you are able and keen, you can PM me a link to the AEP and the source data and I'll take a look. Good Luck.

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Inspiring
February 7, 2022

Could try selecting the mask path with the expression and using Animation > Keyframe Assistant > Convert Expression To Keyframes. You probably want to trim the layer in/out points to a single frame first so you just get the one keyframe. Then copy/paste that into a Position property.

CesarRVGAuthor
Participating Frequently
February 7, 2022

Thanks a lot for your answer and your time.

I already tried that solution, but it seems won't work fine with my data.

I have a resolution of 10 rows of data for each second. For the test 5 minute video I have 3000 rows of data which were used to generated the path. The conversion of the expression to keyframes took like 10 seconds. But the pasting operation of the resulting keyframes into the shape layer's position too about 20 minute to finish (in a i7 with 32GB Ram computer).

There will be videos with 30 or 60 minutes of data, the CSV file will contain like 100,000 rows. I think in that point this operation will be impossible to perform. I need a way to read the path that's already there, the path is also painted as a line in other layer.

Inspiring
February 7, 2022

Just to clarify, when you say 'pasting the resulting keyframes' do you not just need one keyframe that contains the full path? The mask path expression isn't changing over time right? If you didn't trim the layer down to 1 frame before converting and copy/pasting, and were in fact converting/pasting hundreds of keyframes that would significantly slow things down.