# Distance loop between points

Hello, so I created my first script in dynamo that assigns coordinates at two instance parameters of a general annotation family to export a schedule with them. That was my very first time using Dynamo. What I am trying to achieve is having a schedule with the coordinates of specific points and the distance between the points to close the loop. I tried assigning an ascending label at the points through dynamo as well but didn’t make it so I ended up adding another instance parameter that I would fill manually. The question is can I calculate distances between points at an ascending manner (1-2,2-3,3-4,4-5,5-1), what I understood is that I should start from creating the line to connect them to begin with. Sorry for not uploading the script but I was allowed to upload just one picture since I am new user.

Hello @markpen - welcome to the community!

You can do something like follows;

1. I’ve made up some mock-points like you have shown in your image, but you can replace those as a collection from Revit if you want
2. I am using a custom node from the `Springs` package called /W Points.ConvexHull2D which allows you to correctly collect and order points in 2D in order to create a polycurve between them. It’s super cool, because if you have other points inside those loops, it will remove them. You may not need this step, but I thought it useful to include.
3. I am then creating a PolyCurve.ByPoints and putting in a True boolean into the optional input to close that curve. This gives us our full loop!
4. After we have created that PolyCurve, we want to break it down into the component pieces - and use the PolyCurve.Curves node to do this. This gives us 5 curves.
5. And lastly, we simply want to get the length of each of those curves, so we use Curve.Length

1 Like

A similar approach to what @solamour suggested
But based on a function by @Vikram_Subbaiah

SortedDistances.dyn (9.2 KB)

2 Likes

To begin with thank you very much for the time spent. I will be honest with you AmolShah as mentioned it’s the first thing I did so I don’t understand the Code Block. So I followed solamour’s approach that felt easier to understand. Though as you will see, I need to create points from the 2 instance parameters of the the family Easting and Northing. These two parameters have gotten their value from the first script I did which assigns them the survey coordinates accordingly. So is there a way to create points from what I have? Thanks once again

1 Like

Use the Point.ByCoordinates node

1 Like

This time I understood AmolShah and got the hybrid answer I was looking for. You were both really helpfull and fast on answering. Thanks

1 Like

@markpen We’re glad that you found what you were looking for.

Posting just in case if anyone is referring to this topic with unsorted points.

2 Likes