Closest point between sublists

Hi all!

I would like to found the closests point, crossing sublists.

When I try to cross a list of points VS another list of points, the script works well:
ClosetsPoints_list_1.dyn (24.1 KB)


But when I try to cross more than one sublist, the script doesn’t works…:
Closets_v2_list2.dyn (42.4 KB)


Any idea? thanks!

is this node therefore made (i never used it)

1 Like

That’d be the way I would do it.

The fix for @EiPM_XaviColl’s graph is going to be to use list levels and lacing correctly at each of the nodes after the Geometry.DistanceTo node.

Thank EzDoesIT, I tryed the node “Geometry.ClosestPointTo”, and it works to cross points versus other king of geometry (like solids, curves, surfaces…). But it seems that this node doesn’t works correctly wit points versus points…

Thanks JacobSmall for the answer. I tryed several combinations of levels and lacings, but I haven’t got it to work… I don’t know exactly why it doesn’t work with severeal sublists…

I think that the node “Geometry.DistanceTo” should give the same number of items in each sub-list, both in the example of the script “1list vs 1list” and in the example of the script “2 lists versus 2 lists”.
But instead the number of items varies, it’s strange …

maybe you could try Point.FindClosest node from Onion package (that I slowly develop).
I tried it on your script and it is working, I think:

It is available in the package manager.


Can you share your graph?

Yes! here there are

ClosetsPoints_list_1.dyn (24.1 KB) ClosetsPoints_list_2.dyn (51.3 KB)

Very interesting Maciek!

I just tried it in dynamo sandbox 2.3 but it doesn’t work … What version of dynamo have you used?

The node from clockwork will work

1 Like

I am using Dynamo 2.0.3 for Revit.
Maybe I have some Revit Api dependencies in the code, hence the problem…

Hi Jacob,

Here there are my graphs:
ClosetsPoints_list_1.dyn (24.1 KB)
ClosetsPoints_list_2.dyn (51.3 KB)

1 Like

Oooh … What a disappointment, I was super interested in use your script.
Any solution to use it, Maciek?

It was not very smart of me to use Revit API for such a simple task :slight_smile: I will probably update the node someday…
For now you could try this peace of python code:

pointsA = UnwrapElement(IN[0])
pointsB = UnwrapElement(IN[1])

if not hasattr(pointsA, '__iter__'):
	pointsA = [pointsA]
if not hasattr(pointsB, '__iter__'):
	pointsB = [pointsB]

output = []

for pA in pointsA:
	sortedB = sorted(pointsB, key = lambda x:x.DistanceTo(pA))

#Assign your output to the OUT variable.
OUT = output

It does the same thing…take input of two point lists and outputs a list of closest points.

1 Like