Beem and wall distance from Grid

As far as I can see from the image, it is a lacing problem: you are getting the distance from the element with a grid, not with all grids, as the following pattern
element A -> grid 1
element B -> grid 2
element C -> grid 3
(the result is A1, B2, C3)
To achieve the shortest (or largest) distance from grids, you have to check the element witll all of them and, later, taking the min (or max) value:
element A, grid 1,2,3
element B, grid 1,2,3
element C, grid 1,2,3
(the result is A1, A2, A3, B1, B2, B3, C1, C2, C3)
look for the cross product lacing on primer to have a reference.

Here’s my file for your study
ShortestDistanceToElement.dyn (44.3 KB)