by contingencies · 8mo ago · 0 comments
You'd be amazed how hard this is to achieve with open source tools. IIRC modern FreeCAD can't, old FreeCAD can, ~5 ways to achieve it in OpenSCAD don't work properly, Blender keeps shifting-sands and mostly can't but I believe the very latest can maybe do it with difficulty using geometry nodes.
from ocp_vscode import show_all
from build123d import *
od, p, n, d, e = 10 * MM, 12 * MM, 5, 1 * MM, 15 * MM
base_helix = Helix(p, 2.2 * p, od / 2 + 0.001, center=(0, 0, -p))
# retain a small piece below XY plane for orienting sketch
trim_base_helix = base_helix.trim(0.4, 1)
trim2_base_helix = trim_base_helix.trim(0, 0.72)
p0 = trim2_base_helix @ 1
t0 = (trim2_base_helix % 1).normalized()
t1 = Vector(0, 1, 0).normalized()
bisector = (t0 + t1).normalized()
if bisector.length == 0:
bisector = t0 # Fallback if tangents are perfectly opposite
ray = Axis(p0, bisector)
end_pt = ray.intersect(Plane.XZ)
transition_arc = TangentArc(p0, end_pt, tangent=t0)
rh_curve = Curve() + [trim2_base_helix, transition_arc]
profile = (rh_curve ^ 0) * Rot(Z=99) * Circle(d) # rotate seam out of the way
rh_sweep = sweep(profile, rh_curve)
splitter = Plane.XZ * Rectangle(10, 40, align=(Align.MIN, Align.CENTER)).face()
rh_sweep = split(rh_sweep, bisect_by=splitter, keep=Keep.BOTH).solids()[1]
lh_sweep = mirror(rh_sweep, about=Plane.XZ)
both_sweeps = Part() + [rh_sweep, lh_sweep]
cyl = Part() + Cylinder(od / 2, p + e + d / 2)
cyl -= both_sweeps
cyl = split(cyl, bisect_by=Plane.XY)
cyl += mirror(cyl, about=Plane.XY)
show_all()
I also tested the above in the online build123d-sandbox here, which worked great: https://jojain.github.io/build123d-sandbox import copy
from build123d import *
from ocp_vscode import show_all
od, p, n, d, e = 10 * MM, 12 * MM, 5, 1 * MM, 15 * MM
with BuildPart() as thread_segment_builder:
with BuildLine():
path = Helix(p, 1.1 * p, od / 2 + 0.001)
with BuildSketch(path ^ 0) as diamond:
xsection = Polygon((0, d), (0, 0), (d, d / 2))
track = sweep(is_frenet=True)
# Trim the ends to align with Plane.XZ
Box(2 * p, p, p / 2, align=(Align.MIN, Align.MAX, Align.MIN), mode=Mode.SUBTRACT)
with Locations((0, 0, p)):
Box(2 * p, p, p / 2, align=Align.MIN, mode=Mode.SUBTRACT)
# Create the rod end with an extension beyond the threaded section
with BuildPart() as threaded_rod_end_segment_builder:
with Locations((0, 0, -e)):
Cylinder(od / 2, p + e + d / 2, align=Align.NONE)
add(thread_segment_builder.part, mode=Mode.SUBTRACT)
add(mirror(thread_segment_builder.part, Plane.XZ), mode=Mode.SUBTRACT)
# Position and trim the end and mid segments
threaded_rod_end_segment = Pos(Z=-d / 2) * threaded_rod_end_segment_builder.part
threaded_rod_mid_segment = split(threaded_rod_end_segment, Plane.XY)
# Build the rod from copies which is very efficient
threaded_rod = Compound(
children=[Pos(Z=i * p) * copy.copy(threaded_rod_mid_segment) for i in range(n - 2)]
+ [
Pos(Z=-p) * threaded_rod_end_segment,
Pos(Z=p * (n - 1)) * (Rot(X=180) * copy.copy(threaded_rod_end_segment)),
]
)
show_all()Since SolveSpace has a helix tool that can "extrude" any sketch along a helix it should be doable.
https://www.linkedin.com/pulse/dreaded-double-helix-tutorial...
I think the very latest Blender can do it, I haven't got it working yet though.
On the face of it, it seems like you'd define paths and sweep profiles for the material to remove. Is the difficulty in defining the path of the reversing portion, where it's not a helix?
PS. I also use a lot of OpenSCAD. Liked your comment. I started in POVRay so it made a lot of sense after managing non-FOSS CAD people for years.