Clipping Planes with Hatches in Grasshopper

Below is a WIP of a way to use/manipulate a clipping plane, and apply a hatch fill . Most of the code is from things I have posted before, (I will provide links below). It also uses the Human Plugin, (which I use all the freaking time!), for some line weight display . Also, maybe the make2d components can already do this?

It uses 4 custom components:
1 - Retrieve hatch patterns from active Rhino Doc (Human has this)
2 - Apply those hatch patterns to some boundary curves
3 - Apply a material from the active Rhino Doc to preview
4 - Create 1 clipping plane

Material with GHPython - Code Example

Hatch with GHPython - Code Example

Clipping Planes in GH - Discussion

Here is the current example code for the clipping plane from GHPython. (Type hint for Plane input set to Plane, Type hint for F, set to Boolean)
NOTE: this is off the cuff/bespoke code, and is just a working test. mileage may vary.

import Rhino
import scriptcontext as sc
import Grasshopper

if F and Plane:
    # Check if exists in sticky, if not, Add the cutting plane, add GUID to the sticky dict, delete object
    if "cplaneID" not in sc.sticky: 
        AVGuid = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewportID
        NewClipPlane = Rhino.RhinoDoc.ActiveDoc.Objects.AddClippingPlane(Plane, 25, 25, AVGuid)
        sc.sticky["cplaneID"] = NewClipPlane
    # If it does exsist, delete it and create a new one each time this component updates
        AVGuid = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewportID
        NewClipPlane = Rhino.RhinoDoc.ActiveDoc.Objects.AddClippingPlane(Plane, 1, 1, AVGuid)
        sc.sticky["cplaneID"] = NewClipPlane
        print sc.sticky["cplaneID"]
except Exception, ex:
    ghRunTimeMsgLevel = Grasshopper.Kernel.GH_RuntimeMessageLevel

a = Plane

Thank you , very useful
Is there a better way to create one clipping plane with specific id or store the first id and use it again?
Sometimes when i lock objects in Rhino or hide them the script create duplicate clipping plane.

I use GetFillSurfaces to create hatch boundary

1 Like

Hi Chris,

Thank you for your code.
I am trying to implement it with multiple hatches.
I tried different approaches for over three days, and still cannot figure out how to do it properly.
This is the closest I could get to my goal. (The circle isnt working yet). (14.5 KB)

I don’t really need hatches to be “Baked” onto the canvas, I just only need preview with the ability to change properties, without creating(overlapping) new hatches.