Hacker Newsnew | past | comments | ask | show | jobs | submit | Cargo4286's commentslogin

Not perfectly relevant but build123d docs have an example using sympy as part of solving constraints for a design. https://build123d.readthedocs.io/en/latest/tttt.html#t-24-cu...

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()
I also tested the above in the online build123d-sandbox here, which worked great: https://jojain.github.io/build123d-sandbox


This looks on the mark. Congratulations! You have succeeded where others failed.


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).


Yes, AFAIK you are correct that SCAD is incapable of outputting clean STEP files.


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.


Neither Fornjot nor Truck are ready for general use as a BREP CAD kernel.


Here's an ellipsoid in build123d using geometric transformation of a sphere:

    from build123d import *
    mat = Matrix([[2,0,0,0],[0,1.5,0,0],[0,0,0.5,0]])
    ellipsoid = Sphere(100).transform_geometry(mat)
Also, FYI build123d now runs in the browser thanks to OCP.wasm. Example playground here https://jojain.github.io/build123d-sandbox/


If you are using build123d, probably the easiest way is to sketch an ellipse and revolve it.


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.


build123d isn't Microcad


>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.

[1]: https://github.com/gumyr/build123d and docs https://build123d.readthedocs.io/en/latest/


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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: