Neighbours of each point in a nested list

ghpython
unhandled

(mimosapudica) #1

Hello,
I am trying to find the neighbours of each point. then I will measure the distance between each point with its neighbour.
How I can exclude the points on the edge?

import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import scriptcontext as sc

points = []
lines=[]

for j in range (len(curves)-1):
first_points = rs.DivideCurve(curves[j], div)
second_points=rs.DivideCurve(curves[j+1], div)
for i in range(div+1):
Lines=rs.AddLine(first_points[i],second_points[i])
lines.append(Lines)
for line in lines:
row_points = rs.DivideCurve(line, div)
points.append(row_points)

flat_points = [item for sublist in points for item in sublist]

i = 5
j = 7

#orthogonal neighbours
points[i+1][j]
points[i-1][j]
points[i][j+1]
points[i][j-1]

#diagonal neighbours
points[i+1][j+1]
points[i+1][j-1]
points[i-1][j+1]
points[i-1][j-1]