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

3 thoughts on “Cushion Panels Script in Python for GH

  1. this one looks fabulous! Thanks four sharing the script and the GH def as well, I just cannot wait to give it a try. COuld you share the VB script you’ve mentioned as well? It sounds like interesting to do this in VB, I’m curious:)

    • Hi,
      It’s more or less the same routine only written in vb.net and without nested lists, but DataTrees instead. So each branch stands for a nested list in this algorithm. Will post it sometime soon.
      M.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s