Geometry.Distance To: start and end point of the distance

Hello everybody!
I’m trying to find out the shortest distance between two exemplary surfaces / objects.

My problem now is, that I’d like to see the start and end point of those distance. Are there any ideas / hints?

There’s a Geometry.ClosestPointTo node that does this. It might be worth getting the closest point from both geometries and then getting the distance between those points, just to make sure everything is making the same calculations.

1 Like

I’d go with this, but given geometry 1 first find the closest point on geometry 2, then find the closest point on geometry 1 to the new point.

1 Like

Hi,

You can easily do this with “ShapelyShortLine” in the Shapely package. This will give you the most unfortunate point between the 2 geometries.
Here is an example for you:

1 Like

Hello guys and thanks for your replies!

@Nick_Boyts and @jacob.small: both ways give me the same solution between geometry A and B:

But what I´m specially looking for is the shortest distance in the vertical (z) axis (blue one). I have not mentioned it, sorry.

@Durmus_Cesur: What kind of input do I need for those nodes?

Quite a different problem… feels like the best method would be to generate a plane between the two shapes, find the point on that closest to shape 1, and project to shape 2… but not sure that’d work.

Let me think on this one for a bit.

1 Like

I think, I’ve got the solution:

  1. Geometry.ClosestPointTo from geometry B to A
  2. Point.Project on geometry A
  3. Line.ByStartPointEndPoint from 1. to 2. and its length

Now it’s time to check it in a real use case :slight_smile:
Thanks a lot!

Your solution will probably be pretty close in most cases, but not all the time.

Projecting an array of points can be as precise as you need based on the point density and will probably be generally more accurate in the grand scheme of things.

Could you give me an example?

Instead of finding the “closest” point and project it, create an array of points fitting the bounds of one geometry and then project each point onto both surfaces and check the lengths.

Hi guys,

Is there a way to assure that the Geometry.ClosestPointTo function is only directed in z axis direction?

I tried to use the script to estimate the closest distance between the beam (1) an the line below (2). How can it else be that the calculated point has a horizontal offset to the line?

If I try to use the Geometry.ClosestPointTo function the other way around, the point is located on the line but has a horizontal offset, too. View from above:

I also thought about projecting the beam geometry on the line and use it as lower reference. Like this, it can be assured, that the closest point stays in bounds of the beam section viewing from above.

That’s a different question than the closest point.

This should help though: Dynamo Dictionary

1 Like

Thank you for the hint!

Since I want to project the beam element on another Solid, I have to derive the base area of the beam as a curve, because the projection of an Element is not available yet. What would be the best way to do it?

Nevertheless, the first question is not solved: Is there a way / workaround to assure that the Geometry.ClosestPointTo function is only directed in z axis direction?

Thanks in advance!

What would be the best way to create the point array of the base surface of the beam I mentioned below?

Also, it is important to define how many points are extracted from the surface. Which grid would you choose?

Get the bottom surface of the beam and create a UV array.

That’s up to you, based on your needs. We can’t make that decision for you.

Can’t you project a point, not just curves?