Python - Working with arrays

revit
loop
python
geometry
dynamo

#1

Hi Guys,

I’ve very recently picked up python. I’m trying to create a python code that tells me to distance from a curve to a point.

I think I have done this so far, however it only does it for each index. Forr Example:
0 to 0
1 to 1
2 to 2
When I need to it to tell me the distance for every curve to every start point. For example:
0 to 0
0 to 1
0 to 2
1 to 0
1 to 1
1 to 2

If this was a node I could just change the lacing, however as I’m doing in python it’s not that simple to me.

Python Text Link

The node set-up

Code snip it with output

Thanks for help


Divide curve to distance
#2

like this…

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

curves = IN[0]
start = IN[1]
end = IN[2]

result = []
for point in start:
    t1 = []
    for geom in curves:
        t1.append(Geometry.DistanceTo(geom, point))
    result.append(t1)

OUT = result


#3

two questions from rather new users for something looking like the same… is this an assignment somehow?


#4

Perfect, thanks for the help! Nah, working on a script at work. No relation I’m afraid :slight_smile:


Python - Dividing line on point of intersection
#5

allright then… It would not be good style if I helped someone doing their homework :slight_smile:


#6

im not doing homework.im learning by my self. im discovering dynamo