I think I progressed quite a bit but now I’m stuck with generating the output trees with my results in the format I need, i.e., {A,B,C} branches like the original second list with rotation information. I will share what I have in case someone can suggest a solution for the last part of the code.
Particularly, I think I did not fully get this “format”:
x = th.list_to_tree(x, source=[0,0])
Is source=[0,0] suppose to define the branches? If not, that is my problem because I basically stated source=[A,B,C], in an attempt to define the branch {A,B,C} as stated earlier.
My code:
import ghpythonlib.treehelpers as th
import math
pi = 3.1415926535897932384626433832795028841
xc_global_Tree = []
yc_global_Tree = []
zc_global_Tree = []
Iu_Tree = []
Iv_Tree = []
Iuv_Tree= []
Az_Tree = []
Ay_Tree = []
Azz_Tree = []
Ayy_Tree = []
Iy_Tree = []
Iz_Tree = []
for i in range(Points.BranchCount):
path_points = Points.Path(i) # tree structure {A;B;C}
path_points_A = (path_points[0]) # A: path for number of surfaces
path_points_B = (path_points[1]) # B: path for number of cross sections / frames
path_points_C = (path_points[2]) # C: path for intersecting points that define stiffeners of a given shape
for k in range(SProp.BranchCount):
path_sprop = SProp.Path(k) # tree structure {A}
branch_sprop = SProp.Branch(k)
path_sprop_A = (path_sprop[0]) # A: sectional properties of stiffeners of a given shape
if path_sprop_A == path_points_C:
#Retrieve properties at centroid in (x,y) frame - x horizontal, y vertical from SProp Tree
xc = float(branch_sprop[0])
yc = float(branch_sprop[1])
A = float(branch_sprop[2])
Iox = float(branch_sprop[3])
Ioy = float(branch_sprop[4])
Ioxy = float(branch_sprop[5])
Sx = float(branch_sprop[6])
Sy = float(branch_sprop[7])
#Retrieve rotation angle from deg Tree and rotate local xc, yc
angle = deg.Branch(i)[0]
xc_rot = xc*math.cos(pi*angle/180)-yc*math.sin(pi*angle/180)
yc_rot = yc*math.cos(pi*angle/180)+xc*math.sin(pi*angle/180)
#Retrieve global coordinate points from Points Tree
point = Points.Branch(i)[0]
#Retrieve global coordinate points from Points Tree and calculate centroid in the global coordinate system (y,z)
components = point.strip('{}').split(',')
xc_global, yc_global, zc_global = map(float, components)
zc_global = zc_global + yc_rot #Minus(-) or Plus (x)???????
yc_global = yc_global - xc_rot #Minus(-) or Plus (x)???????
#Transformation of Moments of Inertia due to axes rotation
Iu = (Iox+Ioy)/2+(Iox-Ioy)/2*math.cos(2*pi*angle/180)-Ioxy*math.sin(2*pi*angle/180)
Iv = (Iox+Ioy)/2-(Iox-Ioy)/2*math.cos(2*pi*angle/180)+Ioxy*math.sin(2*pi*angle/180)
Iuv = (Iox-Ioy)/2*math.sin(2*pi*angle/180)+Ioxy*math.cos(2*pi*angle/180)
#Steiner theorem to move properties to global reference system (YoZ plane)
#Moments
Az = A*zc_global
Ay = A*yc_global
#Steiner term
Azz = Az*zc_global
Ayy = Ay*yc_global
#Area moment of inertia with respect to global axis (Steiner theorem)
Iy = Iv + Azz
Iz = Iu + Ayy
#Construct output Trees in a structure type {A;B;C}
xc_global_Tree = th.list_to_tree(xc_global, source=[path_points_A,path_points_B,path_points_C])
yc_global_Tree = th.list_to_tree(yc_global, source=[path_points_A,path_points_B,path_points_C])
zc_global_Tree = th.list_to_tree(zc_global, source=[path_points_A,path_points_B,path_points_C])
Iu_Tree = th.list_to_tree(Iu, source=[path_points_A,path_points_B,path_points_C])
Iv_Tree = th.list_to_tree(Iv, source=[path_points_A,path_points_B,path_points_C])
Iuv_Tree = th.list_to_tree(Iuv, source=[path_points_A,path_points_B,path_points_C])
Az_Tree = th.list_to_tree(Az, source=[path_points_A,path_points_B,path_points_C])
Ay_Tree = th.list_to_tree(Ay, source=[path_points_A,path_points_B,path_points_C])
Azz_Tree = th.list_to_tree(Azz, source=[path_points_A,path_points_B,path_points_C])
Ayy_Tree = th.list_to_tree(Ayy, source=[path_points_A,path_points_B,path_points_C])
Iy_Tree = th.list_to_tree(Iy, source=[path_points_A,path_points_B,path_points_C])
Iz_Tree = th.list_to_tree(Iz, source=[path_points_A,path_points_B,path_points_C])