# Macro to make an accumulated line between Point 1 (X,Y), Point 2 (X,Y) and Point 1000 (X,Y) over frames

The result contains “Frame”, “X” coordinate, “Y” coordinate. I’d like to make a line between coordinates corresponding to the frame. In each frame, there is one coordinate.

Frame X Y
1 10 15
2 12 17
… … …

For instance, from the second frame, there should be a line connecting 2 coordinates from 1st to 2nd coordinates and so on over frames(1000).
Could you help me writing Macro. please?

``````numberOfRows = nResults;
for (row = 0; row < numberOfRows; row++) {
frame = getResult("C1", row);
x = getResult("C2", row);
y = getResult("C3", row);
setSlice(frame);
makeLine(????);
}

``````

Hi @Jae,

If I understand correctly, I think you want something like the below?

``````numberOfRows = nResults;
for (row = 0; row < numberOfRows-1; row++) {
frame = getResult("C1", row);
x1 = getResult("C2", row);
y1 = getResult("C3", row);
x2 = getResult("C2", row + 1);
y2 = getResult("C3", row + 1)
setSlice(frame);
makeLine(x1, y1, x2, y2);
}
``````

Let’s say we have this kind of results.

Frame X Y
1 10 15
2 12 17
3 10 13
4 11 18
… … …

After running macro, there should be a line connecting (10, 15, 12, 17) on the 2nd frame of my image, new line connecting(12, 17, 10, 13) with the previous line on the 3rd frame. And new line connecting(10, 13, 11, 18) with all previous line on the 4rd frame. So my all connected line draws a trajectory on the image over frames.

Oh I see, I think something like below should work.

``````lineX = Table.getColumn("C2");
lineY = Table.getColumn("C3");

numberOfRows = nResults;

for (row = 0; row < numberOfRows; row++) {
frame = getResult("C1", row);
currentX = Array.trim(lineX, row+1);
currentY = Array.trim(lineY, row+1);
setSlice(frame);
makeSelection("polyline", currentX, currentY);