Hi All,
I’m quite new in Python, and for the issue I need, there are some things I don’t know how to script them.
For the multi-story wall above, I managed to get the segments of the curves that define the walls (INPUT: GetLocation), recognising the edges of the upper and lower wall.
TASK: I want to check if a segment of the wall in the “i” story exist in the “i+1” story.
To do that, I want to check every segment of the “i” story and compare its Curve.StartPoint and the Curve.EndPoint (X,Y) coordinates to the minimum and the maximum (X,Y) points from the “i+1” and “i-1” story (see green reclangle - I have this as an INPUT for the python node, but this can be created inside the python script).
I want to to this for vertical reinforcement, so the are quite different posibilities for a segment:
- The “i” story segment is contained by a wall in the “i+1” and “i-1” story.
- The “i” story segment is contained only by a wall in the “i+1” or “i-1” story.
- The segment Curve.StartPoint (X,Y) is the same of the Minimum or Maximum for the “i+1” or “i-1” (X,Y) story. The same for segment Curve.EndPoint.
The GOAL here is to tag with some “identificator” (can be a string) the different cases, but always arranged by story.
My Python limitations are that I don’t know how to access levels of the sub-lists and compare them to the Min and Max.
The first python code is:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#Entradas para las coordenadas (X,Y) de los puntos inicial y final de las curvas que crean los muros.
#Start Point
x1 = IN[0]
y1 = IN[1]
#End Point
x2 = IN[2]
y2 = IN[3]
cuenta = x1.Count
i=0
k=1
resultado_actual = []
actual = []
for i in range(cuenta-1):
# Almacena las diferencias para el piso actual
#Corrdenada X
dif_xi = x1[i+1] - x1[i]
dif_xj = x2[i+1] - x2[i]
if dif_xi > 0:
dif_xi = dif_xi
else:
dif_xi = 0
if dif_xj < 0:
dif_xj=dif_xj
else:
dif_xj = 0
actual_x = [x1[i]+dif_xi, x2[i]+dif_xj]
#Coordenada Y
dif_yi = y1[i+1] - y1[i]
dif_yj = y2[i+1] - y2[i]
if dif_yi > 0:
dif_yi = dif_yi
else:
dif_yi = 0
if dif_yj < 0:
dif_yj=dif_yj
else:
dif_yj = 0
actual_y = [y1[i]+dif_yi, y2[i]+dif_yj]
actual = [actual_x, actual_y]
resultado_actual.append(actual)
OUT = resultado_actual
Here is a shot of the script:
I hope my explanation was clear enough.
Hope if you could help me with this or give me some directions.
Thanks in advance for the time!
Cheers!