From 9b57d3b9b7df15f0aeabe9dbc9294e9b9565d124 Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 10 Oct 2024 12:44:39 +0100 Subject: [PATCH 1/2] instructions not needed for all spline --- src/paramak/utils.py | 51 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/paramak/utils.py b/src/paramak/utils.py index a06974ac..f9be40fc 100644 --- a/src/paramak/utils.py +++ b/src/paramak/utils.py @@ -38,43 +38,46 @@ def instructions_from_points(points): def create_wire_workplane_from_instructions( instructions, - plane="XY", - origin=(0, 0, 0), - obj=None, + workplane, ): - solid = Workplane(plane, origin=origin, obj=obj) # offset=extrusion_offset - - all_spline = all(list(entry.keys())[0] == "spline" for entry in instructions) - if all_spline: - entry_values = [(list(entry.values())[0]) for entry in instructions][0][:-1] - res = solid.spline( - entry_values, makeWire=True, tol=1e-1, periodic=True - ) # period smooths out the connecting joint - return res for entry in instructions: if list(entry.keys())[0] == "spline": - solid = solid.spline(listOfXYTuple=list(entry.values())[0]) + workplane = workplane.spline(listOfXYTuple=list(entry.values())[0]) if list(entry.keys())[0] == "straight": - solid = solid.polyline(list(entry.values())[0]) + workplane = workplane.polyline(list(entry.values())[0]) if list(entry.keys())[0] == "circle": p0 = list(entry.values())[0][0] p1 = list(entry.values())[0][1] p2 = list(entry.values())[0][2] - solid = solid.moveTo(p0[0], p0[1]).threePointArc(p1, p2) + workplane = workplane.moveTo(p0[0], p0[1]).threePointArc(p1, p2) - return solid.close() + return workplane.close() def create_wire_workplane_from_points(points, plane, origin=(0, 0, 0), obj=None): - instructions = instructions_from_points(points) - - return create_wire_workplane_from_instructions( - instructions, - plane=plane, - origin=origin, - obj=obj, - ) + + workplane = Workplane(plane, origin=origin, obj=obj) # offset=extrusion_offset + + all_spline = all(entry[-1] == "spline" for entry in points) + + #TODO add check for all straights and do polyline + + if all_spline: + entry_values = [entry[:2] for entry in points[:-1]] + result = workplane.spline( + entry_values, makeWire=True, tol=1e-1, periodic=True + ) # period smooths out the connecting joint + else: + instructions = instructions_from_points(points) + + result = create_wire_workplane_from_instructions( + instructions=instructions, + workplane=workplane, + plane=plane, + ) + + return result def rotate_solid(angles: typing.Sequence[float], solid: Workplane) -> Workplane: From 077d7745f824238c40febeb7b5e8fd5b1d304233 Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 10 Oct 2024 12:54:43 +0100 Subject: [PATCH 2/2] removed incorrect arg --- src/paramak/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/paramak/utils.py b/src/paramak/utils.py index f9be40fc..0ed4e230 100644 --- a/src/paramak/utils.py +++ b/src/paramak/utils.py @@ -74,7 +74,6 @@ def create_wire_workplane_from_points(points, plane, origin=(0, 0, 0), obj=None) result = create_wire_workplane_from_instructions( instructions=instructions, workplane=workplane, - plane=plane, ) return result