Convert planar surface to solid hatch while retaining display colour


I’d like some pointers on how to convert large numbers of planar surfaces into hatches, while retaining the surfaces properties such as display colour etc of each surface/hatch.

I need to do this so I can export the file into illustrator with the shape fills intact.


Hi @benjamin,

I have not tested this a whole lot. But this is the general idea:

import Rhino
import scriptcontext as sc

def test_surface_to_hatch():
    filter = Rhino.DocObjects.ObjectType.Surface
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select planar surface", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
    brep = objref.Brep()
    if not brep or not brep.Faces.Count == 1:
    face = brep.Faces[0]
    tol = sc.doc.ModelAbsoluteTolerance
    if not face or not face.IsPlanar(tol):
        print("Not a planar surface.")
    curves = []
    for loop in face.Loops:
        for trim in loop.Trims:
            if trim.TrimType == Rhino.Geometry.BrepTrimType.Seam:
            edge = trim.Edge
            if edge is None:
    borders = Rhino.Geometry.Curve.JoinCurves(curves, 2.1 * tol, False)
    if borders:
        hatches = Rhino.Geometry.Hatch.Create(borders, 0, 0.0, 1.0, tol);
        if hatches:
            for hatch in hatches:
                sc.doc.Objects.AddHatch(hatch, objref.Object().Attributes)
if __name__ == "__main__":

Let me know if this helps.

– Dale

1 Like

Great! Seems to work for me on Rhino 7 for Mac.

The prompt only allows for single selected surfaces for me. Is it possible to make this work when selecting multiple surfaces?

Many thanks!

Hi @benjamin,

Instead of using RhinoGet.GetOneObject, just use RhinoGet.GetMultipleObjects and loop through the returned object references. (1.3 KB)

– Dale

Apologies for the slow reply - this work great, thank you!