I’m glad you solved it!
Now that you broke free from Dynamo, there’s no need to always use lists for everything
The solid creation and union could be simplified by extracting out the core operations into functions and use the reduce function:
def extrude(curve):
GeometryCreationUtilities.CreateExtrusionGeometry([curve], XYZ(0, 0, 1), MM_to_FEET(1000)))
def union(first, second):
return BooleanOperationsUtils.ExecuteBooleanOperation(first, second, BooleanOperationsType.Union)
solid = extrude(CurveLoops[0])
solid = reduce(CurveLoops[1:], lambda p, n: union(p, extrude(n)), solid)
In the next block you’re extracting the topmost face; assuming the curveloops are closed, you only need to check one point for each curve.
Also, instead of using yet another list, you could directly use a set to hold the Z values.
No need to turn the set into a list to know how many items it holds!
def get_horizontal_face_z(curve_loop):
zs = {FEET_to_MM(Line_GetStartPoint(c).Z) for c in curve_loop}
return next(iter(zs)) if len(zs) == 1 else None
to retrieve all the horizontal curveloops with their z coordinate, you can create a generator:
def get_horizontal_faces_loops(solid):
for face in solid.Faces:
for loop in face.GetEdgesAsCurveLoops():
z = get_horizontal_face_z(loop)
if z is not None:
yield loop, z
now you can just pick the topmost face by using max
with a key
function that reads the second item of the tuple, that is, the z coordinate
topmost_face_loop = max(get_horizontal_faces_loops(solid), key=lambda x: x[1])[0]
the TempCurves
is unneeded, since you have your curves in topmost_face_loop
(your CurveLoop
);
If it’s not a list you could just turn it into one with
temp_curves = list(topmost_face_loop)