Surface to Hatch

Is there anyway to convert a surface to a hatch?

Example Surface:

Surface.PerimeterCurve and then ByJoinedCurves does not work since some of the curves do no touch.


Conversion to hatching has not been verified, but conversion of surface lines to their respective polycurves can be accomplished using Python.

Try copying the code below into a Python nodePreformatted text

–Code–

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

curves = IN[0]
li = [False for x in range(len(curves))]
key = 0
result = {}

def checkPoint(p1, p2):
if round(p1.X, 2) == round(p2.X, 2) and round(p1.Y, 2) == round(p2.Y, 2) and round(p1.Z, 2) == round(p2.Z, 2):
return True
else:
return False

for i in range(len(curves)):
current_line = curves[i]
if len(result) == 0:
result[key] = [current_line]
key += 1
li[i] = True
elif not li[i]:
flag = False
for j in range(len(result)):
current_sp = current_line.StartPoint
val_eps = [x.EndPoint for x in result[j]]
for val_ep in val_eps:
if checkPoint(current_sp, val_ep):
result[j].append(current_line)
li[i] = True
flag = True
if not flag:
result[key] = [current_line]
key += 1
li[i] = True
else:
continue

OUT = [v for k, v in result.items()]


2 Likes

Hatching was created without any problems as it was. :laughing:


2 Likes

I got an error. I will include the snip below. Is the problem because of my list levels?

image

Here is my code I copied from you:

It appears that there is a description error in one part of the code.
The second symbol from the right in the second line does not appear to be a (').
The code itself should work, but the hierarchical structure of the data input to Python needs to match the one I created in my sample.
Of course, it is possible to flexibly change the processing according to the structure of the input data, but that would complicate the code and require more effort.
I am sorry, but I do not have the time to provide this right now. :smiling_face_with_tear: