I’m feeling a bit foolish that I can’t figure this out. The example below is functioning as expected, BUT…for my own edification, I would like to do it without using rhinoscript.
In a ghpython component, I have a for loop that looks at the hatchtable of the active Rhino Doc, then for each item, it makes a corresponding layer, then it constructs the parts needed to make the hatch, creates the hatch, then assigns the objects to the corresponding layer. I couldn’t figure out how to assign the layer using RhinoCommon, so I punted and used rhinoscript. Can someone point me in the right direction for how to assign it using RhinoCommon? below is the relevant section: (outside of this part, there are additional bits that already check if the layer is there before creating it).
\\Requisite other bits before RawHatchTable = sc.doc.ActiveDoc.HatchPatterns for h in RawHatchTable: if h.HasName == True: MakeLayer(h.Name) centerPT = Rhino.Geometry.Point3d(0,spacing,0) labelPT = Rhino.Geometry.Point3d(R+P2, spacing, 0) border = Rhino.Geometry.Circle(centerPT, R) b = Rhino.Geometry.Circle(centerPT, R).ToNurbsCurve() c = Rhino.Geometry.Hatch.Create(b, counter, 0, S) hatchObj = Rhino.RhinoDoc.ActiveDoc.Objects.AddHatch(c) crvObj = Rhino.RhinoDoc.ActiveDoc.Objects.AddCircle(border) txtObj = rs.AddText(h.Name, labelPT, 1.0) rs.ObjectLayer(hatchObj, h.Name) rs.ObjectLayer(crvObj, h.Name) rs.ObjectLayer(txtObj, h.Name) spacing += R*2+P1 counter += 1 else: pass \\Requisite other bits after