I've been trying to create a wave spring using Cadquery but the orientation is all wrong, it rotates with the sweep function instead of staying stable.
At this point I have tried all the arguments available in sweep (like normal, aux spine etc.,) but none of them hit the mark.
I initially tried using a rectangle which should be the case for a wave spring but then for simplicity used a circle. As can be seen from the image the orientation of the sweep changes (signalled by the black path line becoming visible then going behind the sweep over spins) regardless of defining aux spine. here is my code:
import cadquery as cq
import math
t1 = 0
t2 = 50
num_points = 500
radius = 50
offset_in_x = 2
circle_diameter = 4.0
circle_radius = circle_diameter / 2
points = []
aux_points = []
delta_t = (t2 - t1) / num_points
for i in range(num_points + 1):
t = t1 + i * delta_t
x = radius * math.sin(t)
y = radius * math.cos(t)
z = 7 * math.sin(3.5 * t) + 3 * t
points.append((x, y, z))
aux_points.append((x + offset_in_x, y, z+offset_in_x))
wave_path = cq.Workplane("XY").spline(points)
aux_spine = cq.Workplane("XY").spline(aux_points)
result = (
cq.Workplane("YZ")
.center(radius, 0)
.circle(circle_radius)
.sweep(wave_path, isFrenet=False, auxSpine=aux_spine)
)
show_object(result, name="WaveSpring")