DWG Hatch is "flipped" for some reason

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.

Flipped hatch.3dm (61.8 KB)

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… :confounded:

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.

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

1 Like

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.

Hi Jorgen - can you post or send me a dwg that has these flippers?
RH-62043 Open DWG: some hatch planes flipped

-Pascal

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 :slight_smile:

# --- 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)

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

-Pascal

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 :slight_smile: )

Hatches flipped.3dm (31.9 KB)

Hei Jørgen -

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), 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

1 Like