aimo
March 19, 2019, 9:42am
1
Hello all,
i want create hatchs on the layer of the curves/surface. (i can use grasshopper to do that, but in this case/wish, i want to do it without grasshopper :))
in a sample file, i created 2 Layers: Layer 01 (green) and Layer 02 (gold).
when i use rhino command: Hatch, no boundary, i can get all hatchs only on the current aktiv layer.
when i use python script, i can get hatchs on the right layer, but i can’t get hatchs with holes.
here is the Python Script :
import Rhino
import scriptcontext as sc
from scriptcontext import doc
import System.Drawing
import rhinoscriptsyntax as rs
def PrintHatch(srf):
layer = rs.ObjectLayer(srf)
rs.CurrentLayer(layer)
curves = rs.DuplicateSurfaceBorder(srf,1)
hatch = rs.AddHatch(curves)
rs.DeleteObjects(curves)
AllSrfs = rs.ObjectsByType(8 | 16, False, 0)
for i in AllSrfs:
PrintHatch(i)
Can someone help me to chang the Pythonscript, or tell me, which RhinoCommand can i use to create the Hatchs on the layer of the curves/surfaces?
thank a lot!
Test for Hatch.3dm (423.2 KB)
Hi,
Here is a solution that seems to work :
import rhinoscriptsyntax as rs
def PrintHatch(srf):
layer = rs.ObjectLayer(srf)
curves = rs.DuplicateEdgeCurves(srf,1)
joinedCurves = rs.JoinCurves(curves)
hatch = rs.AddHatches(joinedCurves)
rs.ObjectLayer(hatch, layer)
rs.DeleteObjects(joinedCurves)
rs.DeleteObjects(curves)
AllSrfs = rs.ObjectsByType(8 | 16, False, 0)
rs.EnableRedraw(False)
for i in AllSrfs:
PrintHatch(i)
Use rs.AddHatches()
to handle multiple curves
rs.DuplicateSurfaceBorder()
seems to extract only external curve, use rs.DuplicateEdgeCurves()
instead.
You have to join the edge curves to obtain planar closed curves
I also changed the way to set the object’s layer. It avoids changing the active layer of your model.
I like to disable the redraw with rs.EnableRedraw(False)
at the beginning of a script. It runs faster.
aimo
March 19, 2019, 11:18am
3
thank you very much for your cooooool post!!!
Hello,
This seems really nice! I’m also looking in generating hatches on the layers of the curves.
It would be very helpful to retain the layers when applying the hatch command to multiple curves.
Can you help me to understand this?
Thanks for you help!
OK, that was a bit confusing because the topic titles didn’t mention sufaced. And I was more interested in the curves.
So here’s a script that creates hatches from closed curves and places them directly in the same layer as the selected curves. If it helps anyone else.
HatchOnCurveLayer.py (748 Bytes)
1 Like
jdelavaulx
(Jdelavaulx)
October 30, 2024, 8:50pm
6
Hi Pipouille, this is a wonderful script.
Can you make one which does the same but for planarsrf?
Best,
Jeremy