Creating Hatches/Previewing Hatches From GH Python

Earlier this week I learned that I wasn’t understanding some fundamental programming concepts regarding GHpython/GH/Rhino, (thank you @piac for setting me straight!)


As a result, I wanted to better understand what the GHPython component would need to display something like hatches.

NOTE: Before going any further, if you want to do anything with hatches/layers/attributes…you should use Human or Elefront. Those plugins are much more robust/flexible/just plain better.

But… for the sake of taking an exercise to completion, I wanted to learn how to “create” hatches and have them previewed by GH, without baking.
The desired steps were to Read the hatch table, create the hatch Objects, then display them in the Rhino document without baking.
After some tooling around, the key item was Rhino.Geometry.Hatch.CreateDisplayGeometry()

Once again, thank you to all the people that help out those of us that sometimes struggle through. I do not know if this is the best way to achieve this, but it worked, and I consider it a successful conclusion to my exercise!
GetHatchesAndDisplay_GHPY.gh (13.3 KB)

3 Likes

This is a nice sample, @chanley

If I may add two minor comments:

  • rather than adding the drop-down text, or in addition, you could set a new icon (GH standard) by dragging and dropping a 24x24 png image on top of the GhPython component.

  • there’s no need to import scriptcontext and rhinoscriptsyntax in these script, nor change the rhinoscriptsyntax target document, because you do all your work in RhinoCommon (import Rhino). Also, the Grasshopper SDK is not necessary, for the same reason.

2 Likes

Thank you
I create this based on your script, very useful

1 Like

Finally !
Is there a way to use Hatch like in Rhino ?

I’m trying to replicate your code but it isn’t working. Any ideas why this would be?

Or does this thread supersede it?

Create hatch.gh (8.8 KB)

Never mind. I followed the other thread and it seems to be working. Final version here.

Create hatch 2.gh (11.1 KB)

You can use hatch component created from the script.
I already posted it in your thread