Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipping instructions stage for all spline shapes #344

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions src/paramak/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,45 @@ 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,
)

return result


def rotate_solid(angles: typing.Sequence[float], solid: Workplane) -> Workplane:
Expand Down