Cushion Panels Script in Python for GH

cp002pp

This is a code snippet I have been using long time ago written in VB. Just thought of re-writing the code in Python, which is clearer to understand, but I had some problems with datatrees so I had to change the structure of code resulting into a few more lines of code.

cp001pp

This routine utilizes rhinocommon (if you are looking for rhinoscript methods here, in this blog, you are terribly wrong), and simple list management. The code is pretty straightforward, as you can see.

#Library imports
#1
import Rhino.Geometry as rc

#main routine
data_T = []
data_T2 = []
breps = []

for i in range(len(panels)):
    temp_list = []
    temp_list2 = []
    cn = centroids[i]
    nrm = normals[i]
    upper_p = cn+(nrm*height)
    upper_p = rc.Point(upper_p)
    lower_p = cn-(nrm*height)
    lower_p = rc.Point(lower_p)
    temp_list.append(panels[i])
    temp_list.append(upper_p)
    temp_list2.append(panels[i])
    temp_list2.append(lower_p)
    data_T.append(temp_list)
    data_T2.append(temp_list2)

for j in range(len(data_T)):
    ienum = data_T[j]
    ienum2 = data_T2[j]
    b = rc.Brep.CreatePatch(ienum,10,10,0.0005)
    b2 = rc.Brep.CreatePatch(ienum2,10,10,0.0005)
    breps.append(b)
    breps.append(b2)

#outputs
cushion_panels = breps

You can download the definition along  with the python code here.

cushionpanelsdef

Advertisements