Rotation of hatch with rs.AddHatch: counterclockwise change in clockwise

Hello all,

I have develloped a python script that follow a line and will create a lot of small hatch zone. For all hatch, I want to control the rotation, but some time the value of angle is counterclockwise and some time clockwise. If I select the hatch and try to change the value, the hatch stay counterclock or clock depending of what it was. And if I create the hatch in the closed curve with the command _hatch outside of the EditPythonScript, it will be always counterclockwise. Below, a picture of my problem! Do you have an idea to fix my probleme please? Thanks in advance.

In order for us to help, you’ll need to provide a simple script that we can run here. If a 3dm file is need to run the script, please include that too.


– Dale


You can find attached a script and a 3dm file to see the problem. In the 3dm file, I have put three time the same line, because depending on the position of the curve, the result is
different. And to create the line temp2 and temp4 in the function creation_hachure(), depending of the use of “ rs.Command(“_Line”)” or the use of “rs.AddLine” I find different result too.

My version of Rhinoceros is:

Version 6 SR17

(6.17.19235.15041, 23-08-19)

Thanks in advance

debug MCNeel.3dm (29.7 KB)

Debug pour (1.56 KB)

Hi @mdecultot,

Running your script on your file give me this:

Message: eb660bfc-48bf-4332-b9a5-31606e5c9443 does not exist in ObjectTable

  line 1065, in coercerhinoobject, "C:\Users\Dale\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\"
  line 1578, in SelectObject, "C:\Users\Dale\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\"
  line 7, in creation_hachure, "C:\Users\Dale\Downloads\Debug pour"
  line 50, in <module>, "C:\Users\Dale\Downloads\Debug pour"

Sorry, I cannot follow what the script is trying to do.

– Dale

Hello Dale,

I have run this script on three differents computers, and it works each time.

You can find attached a video of how it works on my computer

Hello, did you have time to watch the video that I have post?

@mdecultot - I’ve seen the video. When I run the script in the same manner, I get the error I reported above.

– Dale

What exactly you try to do? What is the point? Maybe is not the best way.

So you have a bug on your computer with the function rs.SelectObject. Perhaps you can work on this bug first? Because I don’t see what I can do more to try to help you to solve the bug on the function rs.AddHatch…

What I want is a different hatching in a zone around a line with different rotations each time. But I need to have this hatching on limited lengths, so it’s why I start to create little area around the line, that I will complete with hatch, as you can see in the video. But the problem is that even if the value of rotation is the same in the code, as you can see in the video, the real value of rotation is varying. If I try the same thing with rs.Command("_Hatch"), all the value of rotation will be good, but this way is not easy to use with an important number of hatching, it’s why I want to run the code with the function rs.AddHatch.

But if you know another way to do it, it will be my pleasure to test it. :slight_smile:

What I try to ask is, what is the purpose? why do you wanna do this hach?.

Is this the result you need?

1 Like

I can’t explain in details why I need this hatch sorry. What you propose it’s not what I need, because I need always the same orientation of hatch, not depending of the line, but depending of the axes X,Y.

But I’m interested of the code that you have used to do that, perhaps I can find a way to do what I want.

@mdecultot you can try scripting the Hatch command instead of using rs.Addhatch:

rs.Command("-hatch _Boundary=No _Enter _Pattern {} _Rotation {} _Scale {} _Enter".format("Hachures1", angle, pitch)) #<--- use command instead of rs function (1.9 KB)

that should work like you expect.

1 Like

Thanks for this solution. I just have to make some adjustements certainly due to my french version like

instead of rs.Command("-hatch

and rs.Command("_Offset {0} e _Enter"
instead of rs.Command("_Offset {0} B _Enter"

but it works :), thank you very much