# Closest point from long list to a point in a shorter list

**URL:** <https://forum.dynamobim.com/t/closest-point-from-long-list-to-a-point-in-a-shorter-list/58099>\
**Category:** Uncategorized\
**Created:** [December 8, 2020, 3:14pm UTC](https://forum.dynamobim.com/t/closest-point-from-long-list-to-a-point-in-a-shorter-list/58099 "2020-12-08T15:14:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [December 8, 2020, 9:37pm UTC](https://forum.dynamobim.com/t/closest-point-from-long-list-to-a-point-in-a-shorter-list/58099/2 "2020-12-08T21:37:35Z")

</div>

Hmm, without seeing the internal of the custom node (perhaps there is an issue with reading the correct index within) I can only offer another option.  
Give this a try 😉

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/dbde91570bfdaf6a3f4dc225db175086c2712582.png)

```
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Inputs
short_list = IN[0]
long_list = IN[1]

# Output list
result = []

# Loop check for each point in the short list
for s in short_list:	
	# List for distances
	dist = []
	for l in long_list:
		# Distance to point s
		d = Geometry.DistanceTo(s,l)
		dist.append(d)
	# Lowest distance in list		
	min_d = min(dist)
	# Index of lowest distance in list
	min_ind = dist.index(min_d)
	# Get the closest point from the long_list
	closest_p = long_list[min_ind]
	# Add the point to the results, as it is the closest to the point from the short list
	result.append(closest_p)

# Output the results
OUT = result
```

---

_[View the full topic](https://forum.dynamobim.com/t/closest-point-from-long-list-to-a-point-in-a-shorter-list/58099)._
