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.
#imports 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() obj_types.append(my_type) #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: objs.append(obj) print("found it") else: if obj.NickName == Comp_name: objs.append(obj) print("found it") #bake the component if Bake == True: for obj in objs: #create an empty GUID list ids = List[Guid]() obj.BakeGeometry(rcdoc,attr,ids) print("baked the dimension elements") doc_components = obj_types