How to load the default Hatches

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?

You need add something like this to load up the default hatches if they haven’t been called upon yet.

  private void AddDefaultHatchesToHatchTable()
      //Check to make sure the system defaults are in the hatch table
      //If they are not, let's add them back

      var hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Solid.Name);
      if (hatch_id == null)

      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Hatch1.Name);
      if (hatch_id == null)

      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Hatch2.Name);
      if (hatch_id == null)
      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Hatch3.Name);
      if (hatch_id == null)

      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Dash.Name);
      if (hatch_id == null)
      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Grid.Name);
      if (hatch_id == null)
      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Grid60.Name);
      if (hatch_id == null)

      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Plus.Name);
      if (hatch_id == null)

      hatch_id = Document.HatchPatterns.FindName(HatchPattern.Defaults.Squares.Name);
      if (hatch_id == null)

1 Like

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();’?


So I got it working with

using Rhino.DocObjects;

var hatch_id = doc.HatchPatterns.FindName(HatchPattern.Defaults.Hatch1.Name);
if (hatch_id == null)

Thanks Travis!

1 Like