# DWG Hatch is "flipped" for some reason

**URL:** <https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304>\
**Category:** Rhino for Windows\
**Created:** [December 11, 2020, 2:09pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304 "2020-12-11T14:09:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [December 11, 2020, 2:09pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/1 "2020-12-11T14:09:36Z")

</div>

Hi, I imported a DWG and wanted to change the fill to lines and see that some of the hatches are “flipped” or “mirrored” or something, resulting in the rotation going the opposite way.

All of these hatches has the same settings, and all are planar and on the same plane.  
The one to the right is a remake of the one in the middle.

Any idea what causes this? I see that I can’t use the “Flip” command on hatches.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/b/d/abdd1c60d0805fc2970a02438f19d98e171316ef.png)

[Flipped hatch.3dm](https://discourse.mcneel.com/uploads/short-url/iWwI7KzFk0fQOUH135j4q9boVj5.3dm) (61.8 KB)

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 11, 2020, 3:25pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/2 "2020-12-11T15:25:57Z")

</div>

Yeah, the plane of the hatch is somehow ‘flipped’ (like it was made from the bottom view instead of the top) so the 45° goes in the opposite direction. It’s weird… DupBorder on all and then make new hatches using Match to the original, then discard the originals… I see Match inside Hatch _STILL_ does not match hatch color and/or layer though… 😖

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [December 11, 2020, 4:23pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/3 "2020-12-11T16:23:05Z")

</div>

Yeah, I Guess Hatch should be included in the flip command.  
And I have my own tool for hatch-matching, so I’ll just rewrite to remake the entire hatch.

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [December 11, 2020, 4:56pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/4 "2020-12-11T16:56:58Z")

</div>

Hi Joregen, yeah - the hatch plane Z is flipped to -1 on that one hatch. I guess for now, as a cheap way out, you can set the hatch PatternRotation, in your script, to -1\*PatternRotation… Just flipping the plane requires more monkeying around to compensate for the change in location.

I’ll see if it is possible to Flip hatches.

-Pascal

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [December 12, 2020, 12:01am UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/5 "2020-12-12T00:01:38Z")

</div>

Thanks Pascal. I’d rather rebuild them to make sure the export back properly though.  
I guess _if_ they can be flipped, then it would be good to flip them on import, if possible.

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [December 12, 2020, 12:42am UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/6 "2020-12-12T00:42:31Z")

</div>

Hi Jorgen - can you post or send me a dwg that has these flippers?  
[RH-62043](https://mcneel.myjetbrains.com/youtrack/issue/RH-62043) Open DWG: some hatch planes flipped

-Pascal

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 15, 2021, 1:37pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/7 "2021-01-15T13:37:55Z")

</div>

Hi Pascal, I just made a script to fix flipped hatches and discovered that rs.AddHatch() makes the same flipped hatches, so I had to use rs.Command(“Hatch”) instead.

So I guess it is an error in the RhinoCommon add hatch thingo 🙂

```python
# --- DWG Rehatch

import rhinoscriptsyntax as rs

def Rebuild_Hatch(hatch_id):
    orig_Fill = rs.HatchPattern(hatch_id)
    orig_Scale = rs.HatchScale(hatch_id)
    orig_Rotation = rs.HatchRotation(hatch_id)
    orig_Layer = rs.ObjectLayer(hatch_id)
    orig_Color = rs.ObjectColor(hatch_id)
    
    
    rs.HatchPattern(hatch_id,'Solid')
    obj = rs.ExplodeHatch(hatch_id, delete=True)
    
    crvs = rs.DuplicateEdgeCurves(obj)
    
    #newHatch = rs.AddHatch(crvs, orig_Fill, orig_Scale, orig_Rotation)
    rs.SelectObjects(crvs)
    rs.Command("_-Hatch _Enter _Enter",False)
    newHatch = rs.LastCreatedObjects()
    
    rs.DeleteObjects((crvs,obj))
    
    rs.ObjectLayer(newHatch, orig_Layer)
    rs.ObjectColor(newHatch, orig_Color)
    # --- Add these since rs.AddHatch() does't 'work' correctly.
    rs.HatchScale(newHatch, orig_Scale)
    rs.HatchRotation(newHatch, orig_Rotation)

hatch_ids = rs.GetObjects("Get Hatch to rebuild", rs.filter.hatch)
if hatch_ids:
    for hatch_id in hatch_ids:
        rs.EnableRedraw(False)
        Rebuild_Hatch(hatch_id)
        rs.EnableRedraw(True)

```

---

<div class="post-metadata">

**Author:** ![pascal](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pascal/32/479395_2.png) [@pascal](https://discourse.mcneel.com/u/pascal)\
**Post date:** [January 15, 2021, 6:01pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/8 "2021-01-15T18:01:10Z")

</div>

Hi Jorgen - see if flipping all the curve directions does anything useful for rs.Addhatch()

-Pascal

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 21, 2021, 2:29pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/9 "2021-01-21T14:29:02Z")

</div>

Yup, I can confirm that reversing the curve flips the hatches.  
But that doesn’t help much since I don’t have an automated way of knowing if a curve rotates clockwise or not.

But why is that? And since the Rhino Command “Hatch” automatically does this I would like for rs.addhatch() to do the same (please 🙂 )

[Hatches flipped.3dm](https://discourse.mcneel.com/uploads/short-url/cjPzgyWUmv6yc4DPkCFQV2hqPFl.3dm) (31.9 KB)

---

<div class="post-metadata">

**Author:** ![wim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/wim/32/747482_2.png) [@wim](https://discourse.mcneel.com/u/wim)\
**Post date:** [November 24, 2021, 2:38pm UTC](https://discourse.mcneel.com/t/dwg-hatch-is-flipped-for-some-reason/114304/10 "2021-11-24T14:38:58Z")

</div>

Hei Jørgen -

> [@Holo](#):
>
> And since the Rhino Command “Hatch” automatically does this […]

FWIW, With the new dynamic hatching of sections in the Rhino 8 WIP, we found that the direction of hatches could be inconsistent at times. To try to solve this ([RH-66249](https://mcneel.myjetbrains.com/youtrack/issue/RH-66249)), it looks like the Rhino `Hatch` command will no longer automatically use a flipped version of the input curves to produce a hatch that goes in the same direction. The direction of the curve now determines the direction of the hatch.  
-wim
