Creating a method in python script not working

Hi, i wanted to create a method to avoid repetitive typing, but I’m not sure where the mistake lies in my code, as in why is it returning 0

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
       
#METHOD
def get_distances(list, object):
        distances = []
        for l in list:
            d = l.DistanceTo(object)
            distances.append(d)
            return distances

#INPUT
curves = IN[0]
surface = IN[1]

distances = get_distances(curves, surface)

OUT = distances

nevermind :sweat_smile: turns out that any curves touching the surface returns 0…

1 Like

@lrsmns ,

do have a screenshot, what are you do exactly? in the geometry hierachie you have points → perimeter-curves → surface

KR

Andreas

I think you have the return too far over and should be tabbed back one as per the below.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
       
#METHOD
def get_distances(list, object):
        distances = []
        for l in list:
            d = l.DistanceTo(object)
            distances.append(d)
        return distances

#INPUT
curves = IN[0]
surface = IN[1]

distances = get_distances(curves, surface)

OUT = distances
1 Like

yes this was also the problem! thank you :sweat_smile:

1 Like