Ok here is my result, which matches up well with the examples I have found from McMaster Carr. Note that not all STEP importers are robust enough to deal with files from OCCT based CAD packages. As I mentioned previously there are transition arcs from the left to right hand helices on both ends which enable the automatic reversing behavior.
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()
build123d can absolutely accomplish this. I downloaded a STEP file of a self-reversing (diamond) thread part from McMaster Carr for analysis. I will reply when I finish a recreation of it. Based on my analysis of the STEP I most likely will start with a regular left and right helices that are trimmed slightly before they intersect at the end. From there will need to apply constraints for tangency with the helices while staying fixed on the cylindrical body. There are multiple ways to achieve this. The next step is to perform a sweep (cut) on half of the transition plus one side of the helix. This can be done in two stages to avoid self intersecting sweep geometry (a big no-no in most/all BREP CAD kernels).
Also worth looking at this project https://gitlab.com/dmytrylk/solve123d which adds constraints on top of build123d using a jax-based numerical solver.
This feature technically already exists in build123d + OCP CAD Viewer (ocp_vscode). You can click a feature in GUI and it will copy the index to clipboard, you can then apply e.g. fillets to it on the code side. See here https://github.com/bernhard-42/vscode-ocp-cad-viewer/blob/ma...
The biggest caveat is that there is currently absolutely zero mitigation for toponaming. This feature is extremely brittle, so I tend not to use it very much -- but I am still glad it exists for those situations when composing a selector is too annoying.
The definition of an ellipsoid is that it can have three independent radii. A revolved ellipse only has two independent radii. If only two independent radii are needed then yes I agree with you, but I wanted to provide a fully qualified answer.
>OpenSCAD however fails spectacularly for any kind of complex filetting situation when compared to tools like Fusion or even FreeCAD (FreeCAD's UI is an abomination though).
build123d[1] is based on the same kernel as FreeCAD and has full support for complex filleting situations. Furthermore it also has first class support for 1D and 2D primitives which enable a more flexible design approach.
> The morphological ops in OpenSCAD (minkowski type stuff) are a very poor substitute to real fillets, and are extremely slow (underlying algos are all polynomials in number of triangles) when your objects get complex, and they are global operations, it is extremely hard to limit their action to a localized part of your object.
Agreed.
> Another thing that's a real pain in OpenSCAD: you cannot "probe" (measure) your existing object at a certain stage, grab the result of that measurement and re-use it in the rest of the code. MAJOR limitation.
This is another area where build123d excels. You can create a line and query its length. You can create a face and query its area, position, size, bounding box, etc. You can select parts of a solid and perform operations on them (like a chamfer/fillet, or use them as a reference for positioning). You can query the geometric type of any topological entity; e.g. is this curve linear, a circular arc, elliptical, or a spline?
build123d is IMHO easily one of the most powerful CAD packages that are not well known by a wide audience (owing in part to its ~3 year history). OpenSCAD is a fantastic tool; it was my introduction to CodeCAD and I used it for years. Therefore, my objection isn't to OpenSCAD itself, but to the limitations inherent in any single tool -- and in this case, those limitations are quite significant.
You should really look at build123d -- it is a full CAD package including 3D but it also treats 1D and 2D as first class citizens.
Your idea about drawing lines is already supported in build123d:
m1 = Line((0,0),(0,24)) # vertical line
m2 = Line(m1@1,m1@1+(24,0)) # horizontal line starting at the end of m1
Further you could use logic based on some ruleset to place stock symbols on these "construction lines". It is also very easy to create custom objects that would conform to your exact syntax above.
reply