Bake GH Components via Python


1500 Nodes per iteration

The other day I needed to translate some GH dimensions to native rhino dimensions. Not only that , but it was a sequence of steps in a parametric model, which means that I had to repeat the same process for about a 1000 times. Obviously the old-fashioned right click wasn’t working for me,

Although, I already have some routines that can bake geometry directly to rhino (and export it) , the Dimension and Preview components of Grasshopper3d don’t have any geometry output. Nonetheless, i needed the leader(or marker ) tag utility.

I wrote this small snippet to bake, not only dimensions, but any component type and with a specific name , to a specific layer, without much hustling. I just put it out there for people to use, however I have to warn you that it was written in a couple of minutes, so its almost certain that it will contain many bugs.

Please let me know if you experience one, or if you have a possible suggestion or fix.

Enjoy a usual at the [Sub]Code Page. Python labeled defs.

import Grasshopper as gh
import Rhino as rc
import ghpythonlib.components as comp
from System import *
from System.Collections.Generic import *

#Active Rhinodoc
rcdoc = rc.RhinoDoc.ActiveDoc
#Active GH document
my_ghdoc = ghenv.Component.OnPingDocument()
attr =rc.DocObjects.ObjectAttributes()

# Bake the dimensions in the specified layer called Dimensions
#if it doesn't exist it used the default
attr.LayerIndex = rcdoc.Layers.Find(L,True)

# Iterate the active objects in the current GH file and find the one of the specific type
#if there are many look for the one with the name
objs = []
obj_types =[]
for obj in my_ghdoc.ActiveObjects():
 my_type = obj.GetType()
 #uncomment the next line if you want to see all the component types in the document
 if str(my_type) == Comp_type :
 if Comp_name == None:
 print("found it")
 if obj.NickName == Comp_name:
 print("found it")
 #bake the component
 if Bake == True:
 for obj in objs:
 #create an empty GUID list
 ids = List[Guid]()
 print("baked the dimension elements")

doc_components = obj_types

Dynamic Display Mode Attributes Rhino / GH

hex-grids_dif_widths_dsI dug out an old C# code snippet to change the display widths of curves in the Rhino viewport, by dynamically altering the visual style attributes.

It was an answer for a question on the Grasshopper3d forum (see the thread here), so I thought of tidying up the code and posting it here (probably just to convince myself that I still have the time to be posting things).

Not much to say, just change how your curves look in the rhino viewport through Grasshopper. I am sure that someone might find it useful.

Code in Python below and the file as usual at the [Sub]Code page.


#[Dynamic Display Attributes] was written by Marios Tsiliakos on 21 / 06 / 2015 in grasshopper 0.9.0076
#This definition is for the pubic domain feel free to use it , share it and modify it, by providing proper citing.
#The author, Marios Tsiliakos of , makes no warranty, expressed or implied,
#as to the usefulness of the software and documentation for any purpose.If this tool is used for commercial purposes please notify the author.
#This work is licensed under a Creative Commons Attribution-Share Alike 3.0
#for more information visit

import Rhino.Display as rd

# create some empty arrays
display_modes  = []
display_modes_names  = []
#retrieve the list of Display modes on the document
display_modes =  rd.DisplayModeDescription.GetDisplayModes()
#find out their names
for i in range(len(display_modes)):

#pick the display style that you want
for j in range(len(display_modes)):
    if display_modes_names[j] == mode:
        disp_index = j
selected_mode = display_modes[disp_index]

if execute == True:
    selected_mode.DisplayAttributes.CurveThickness = width
    print("Changed the display option settings for visual style :  " + y)
    selected_mode.DisplayAttributes.CurveThickness = 1
    print(y+ " Display style reset to default settings")

Triaxial Waffling Grasshopper3d Definition


Almost 4 months after my last post..:( i have been really busy lately , mostly with amazingly interesting stuff that I’ll have the time (me thinks!) to unveil in the near future, plus the development for the next build of Nudibranch  to be up-to-date with the new grasshopper version 0.9.0052.

But just to get things rolling and before moving into any major update, I decided to share a fabrication oriented definition of mine, that was developed quite a long time ago. I tried to narrow it down , clean it up and share it along with a small code snippet in Python to generate dot text objects in the rhino viewport (this is now embedded in the new gh), but it serves the general purpose of learning how to interact with rhino objects through Gh.




On the other hand, this definition is really useful (though my point of view at least) especially for the many advantages it has over the normal 2-dimensional waffling system, mainly in terms of rigidness and detail. At the same time this fabrication methodology provides a denser structural framework for any possible post-processing routine in order to describe better the analysed and fabricated design (most of the times a freeform, double curved surface or object) like for example the implementation of a gap filling material like stucco, cement or resin forming somehow an interesting composite system.



The system takes on single surface and translates it into ready to laser-cut stripes laying on three different grid systems, + tags + the quantification of the joints of the system(python snippet). The code of which is just a few lines as you can see below.

import Rhino

dots = []

att = Rhino.DocObjects.ObjectAttributes()
att.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject
att.ObjectColor = col

for i in range(len(pos)):
 dot = Rhino.Geometry.TextDot(text+str(i),pos[i])
 if bake == True:
 D = Rhino.RhinoDoc.ActiveDoc.Objects.AddTextDot(text+str(i),pos[i],att)

Dots= dots

Let me know if there is any way to improve this definition or if bugs are brought up.  You can grab it the usual place ..