I made a script that sucessfully bakes
Breps, but when I try using the same script to bake Block instances (geometry) it fails. Why does it fail, and what code to use to properly “bake” Block instances?
This code fails for blocks but works fine for Breps :
import rhinoscriptsyntax as rs import scriptcontext as sc import Rhino # Set Name and Bake GH objects. if active: if G: i = StartIx for obj in G: # Script context = Grasshopper sc.doc = ghdoc # Get the geometry info for later baking dobj = rs.coercerhinoobject(obj) geom = dobj.Geometry attribs = dobj.Attributes # Script context = RhinoCAD sc.doc = Rhino.RhinoDoc.ActiveDoc # "BAKE" (sort of) new_ref = sc.doc.Objects.Add(geom, attribs) # NAME new_name = BaseName + "_" + str(i) rs.ObjectName(new_ref, new_name) i += 1 # LAYER rs.ObjectLayer(new_ref, LayerName) out = G