Is there a way to get the closest object?

I want to have a list of panels, and then filter it to one panel based on how close it is to a selected object (in this case, a light fixture). Is there a way to do this?

I was thinking about doing the Geometry.ClosestPointTo node by extracting the xyz coordinates from the objects using Element.GetLocation and then comparing the two, but I don’t know what to do from there. Any ideas?

I used the following in one of my graphs. I’ve copied a portion over it for you to take a look at. I already had the location data from earlier so your list structure may be different. It also compared lists of varied lengths (eg, 10 panels against 3 fixtures) so the lacing / list levels used may be different in your application. However it should be a reasonable starting point.

I imagine there’s a more elegant solution out there but it is a place you can start.