The default Grasshopper component 'Pattern Hatch ’ (PHatch) allows for generating hatches previews, but you cannot use the curves or set the color. The Human plugin has the component ‘CreateHatch’ which does give the curves as output. However, this requires a ‘Hatch Pattern Name’ which must have been created in the Rhino document already.
My problem is that a new Rhino document has an empty HatchTable. I get this error when trying to list the available hatches with ‘rs.HatchPatternNames’:
" ‘GrasshopperDocument’ object has no attribute ‘HatchPatterns’ "
Somehow there is a default list of hatches available as soon as you open ‘File > Properties’ and go to ‘Document Properties > Hatch’. Press ‘OK’ there and Grasshopper will tell me, through the Human component ‘Hatch Table’, that there are now 9 hatches available.
So how can I activate that default list of hatches through Grasshopper? Is there a C# or Python command that can load in that default hatch list?
Thank you so much! I think this is it, but I haven’t got it working yet:
Error (CS0103): The name ‘Document’ does not exist in the current context
Error (CS0103): The name ‘HatchPattern’ does not exist in the current context
I guess I need something like ‘Document = Rhino.DocObjects.ActiveDoc();’?
EDIT:
So I got it working with
using Rhino.DocObjects;
//Hatch1
var hatch_id = doc.HatchPatterns.FindName(HatchPattern.Defaults.Hatch1.Name);
if (hatch_id == null)
doc.HatchPatterns.Add(HatchPattern.Defaults.Hatch1);