Find the entries after Geometry.ClosestPointTo

Hello,
I’m starting to get lost in my reasoning and complicate my script (I removed the part that was becoming a real gas factory)
I have a difficulty with the Geometry.ClosestPointTo node to find the elements corresponding to the result
It would be necessary to know the index of the line as well as the index of the point corresponding to the result (in fact the sheath groups)
Is it possible to have this result in a simple way, or with a python script?


Are you trying to find the closest element by distance?

yes, make groups (of 2 or 3 parallel elements) as close as possible as in the drawing

Compose a function using a Function Compose node that consists of Element.Geometry and a Geometry.DistanceTo node. Then run that function into a List.MinimumItemByKey node where the list are the elements and the key is the function. Not sure how to work with the lacing, but by the sounds of it you don’t have a clean automation (what if the newest item to thing A is also the newest item to thing B and they are too far to be in a group?)

It’s not perfect, but for now, the reference list is the list that contains the most elements (here 4) and the other list 3
I select a point each trunk of the group of 4 elements and the project (geometry.closestPointTo) on the other group of 3 elements.
Now, for each point I would like to find the corresponding element.
I tried with BoundingBox and BoundingBox.Contains, it seems to work, but I would like to find a more “clean” way

The method I outlined above is likely your best bet, but scaling is going to be an issue.

What is your purpose for grouping things?

Likely better to reconsider the process here. Reduce to small groups by other portions of the dataset (system, room, quadrant in the structural grid, etc.) and then look for proximity in another way.

I tried your function method, but don’t think I understood it well.

This method seems to work
But still open to a better idea :slight_smile:

Missing the Function Compose node, which should have the Element.Geometry and Geometry.DistanceTo node wired into it. There should be no input on the Element.Geometry and the first input on the Geometry.DistanceTo should be empty, but the point should be the second input. Wire the Function.Compose into the MinimumItemByKey node and see what you get with that.

Sorry I didn’t understand, because I don’t know Function Compose
Is my schema correct?
But I’m not on inputs anymore.
I found an error upstream

Looks correct, but as noted before you’ll have a lacing/list structure to deal with and this node won’t do that directly.

What is your end goal? Why are you doing this?

I work on the supports (Hanger)
Find the ducts side by side
distance between ducts
calculate common height
etc…
My script works with 2 sections (example: group 1 of the drawing)
Now I would like to do it for a larger part of the network

1 Like

Thank you for your time
Goodbye

Does the angle of the ducts matter? As in, if a duct is 15 degrees off angle to the other, can they be grouped?

I’m assuming the goal is to minimize the number of supports in total?

This feels like an optimization problem where you need to define each possible location, select a first location, gather supportable ducts and remove those from the list of all ducts, then proceed to the next closest location. This process repeats until all equipment is supported.

All of that said, this is a rather difficult problem to solve, and will take some strong skills with processing not just geometry but adjacencies. Start by limiting the selection to a single plenum space. After that look into matrix based method of grouping similar to VASA, where you gather items in an XY grid within the plenum. Anything with a common X or is on the same row, common Y is on the same column, and diagonal adjacencies are one above or below the X or Y value. Scale down your resolution as much as tolerable and you should have a good start. From there generation is done by picking a X and Y value to start with, gathering all the unsupported equipment in that celll, and testing adjacent cells within the given distance that a support can carry. Find the solution for a hanger which supports the most equipment and move to the next cell either by distance from the previous, or by procedural sampling.

Good luck, there is a good amount of effort involved in building this, but the potential benefit seems very significant.