# Surface to hatch (inverse of explode hatch)

**URL:** <https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736>\
**Category:** Grasshopper\
**Tags:** rhino, grasshopper, python, vbscript\
**Created:** [June 14, 2019, 7:41am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736 "2019-06-14T07:41:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![arcade.smith](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/arcade.smith/32/506800_2.png) [@arcade.smith](https://discourse.mcneel.com/u/arcade.smith)\
**Post date:** [June 14, 2019, 7:41am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/1 "2019-06-14T07:41:45Z")

</div>

Just say i have 22,000 trimmed **planar** surfaces

I want to hatch them, like the reverse of explode hatch

is there any possible way to do this? using rhino common or C# / vb / python /

thanks

arkadius

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [June 14, 2019, 8:17am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/2 "2019-06-14T08:17:37Z")

</div>

this should work:

```
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

def hatchPlanarSrfs():
    """
    hatch all selected planar surfaces
    tested in Rhino 6
    """
    
    
    
    srfs = rs.GetObjects("select planar surfaces to hatch",8)
    if not srfs:
        return
    for srf in srfs:
        
        srf = rs.coercebrep(srf)
        face = srf.Faces[0]
        if not face.IsPlanar():
            continue
        edges = srf.Edges
        edges = [edge.DuplicateCurve() for edge in edges]
        edges = Rhino.Geometry.Curve.JoinCurves(edges)
        
        hatch = Rhino.Geometry.Hatch.Create(edges, 0, 0, 0)
        sc.doc.Objects.AddHatch(hatch[0])
    sc.doc.Views.Redraw()

if __name__ == " __main__":
    hatchPlanarSrfs()
```

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [June 14, 2019, 8:21am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/3 "2019-06-14T08:21:14Z")

</div>

@Gijs,

With this script, you completely solved this issue here 😜  
[Clipping Plane Fills! Please](https://discourse.mcneel.com/t/clipping-plane-fills-please/84186)

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [June 14, 2019, 8:31am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/4 "2019-06-14T08:31:12Z")

</div>

> [@ivelin.peychev](#):
>
> With this script, you completely solved this issue here 😜

don’t quite get this? can we access the intersection boundary curve then?

---

<div class="post-metadata">

**Author:** ![arcade.smith](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/arcade.smith/32/506800_2.png) [@arcade.smith](https://discourse.mcneel.com/u/arcade.smith)\
**Post date:** [June 14, 2019, 8:43am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/5 "2019-06-14T08:43:03Z")

</div>

Yes this works in a sense, we can also do this in gh, say get brep edges and create hatch, however i was wondering how rhino computes surface from hatch, and if there was a completely inverse method, as it only takes a matter of seconds to explode loads of hatches to srf, but the inverse option above takes along time to compute [but still works].

thanks,

arkadius

---

<div class="post-metadata">

**Author:** ![arcade.smith](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/arcade.smith/32/506800_2.png) [@arcade.smith](https://discourse.mcneel.com/u/arcade.smith)\
**Post date:** [June 14, 2019, 8:53am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/6 "2019-06-14T08:53:04Z")

</div>

So a hatch can be queried if it has a ‘BrepForm’

“[HasBrepForm]”

and:

“Returns true if the Brep.TryConvertBrep function will be successful for this object”

"TryConvert:

Provides implementation for type conversion operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations that convert an object from one type to another."

So would there be a way to impliment a conversion like this\> :?

_ **HasHatchForm** _

_ **Hatch.TryConvertHatch** _???

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [June 14, 2019, 9:05am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/7 "2019-06-14T09:05:38Z")

</div>

not sure what’s your problem, because I just tested it at 12000 surfaces and it took only a few seconds?

whereas doing it in Rhino directly gives me an endless ‘sorting… press esc to cancel’ prompt

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [June 14, 2019, 9:25am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/8 "2019-06-14T09:25:58Z")

</div>

> [@Gijs](#):
>
> don’t quite get this? can we access the intersection boundary curve then?

yes, in that thread I posted a script that gives you the surface of the intersection. converting that to hatch and you’re done 😜

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [June 14, 2019, 9:30am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/9 "2019-06-14T09:30:10Z")

</div>

> [@ivelin.peychev](#):
>
> yes, in that thread I posted a script

can you point me to it? can’t seem to find it

---

<div class="post-metadata">

**Author:** ![ivelin.peychev](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ivelin.peychev/32/676038_2.png) [@ivelin.peychev](https://discourse.mcneel.com/u/ivelin.peychev)\
**Post date:** [June 14, 2019, 10:02am UTC](https://discourse.mcneel.com/t/surface-to-hatch-inverse-of-explode-hatch/84736/10 "2019-06-14T10:02:15Z")

</div>

> [@Gijs](#):
>
> can you point me to it? can’t seem to find it

Follow the link on this post:

> [@Clipping Plane Fills! Please](https://discourse.mcneel.com/t/clipping-plane-fills-please/84186/19):
>
> Have any of you actually use the search option on the forum? That should get you going. Thank @nathanletwory for that.
