Live data from Hacker News

CadQuery is an open-source Python library for building 3D CAD models

cadquery.github.io

51–60 of 70 posts

Re: CadQuery is an open-source Python library for building 3D CAD models

#51

Interesting. I have played with OpenScad a bit. This looks similar - i guess the difference is the syntax is python - any other major differences

Oh boy. The major difference is coordinate transformations, global/local/face. OpenScad basically leaves you alone with math you should figure out on your own. Also it's math heavy for all other stuff, for example tangents, smooth connections, intersection coordinates, etc.

Re: CadQuery is an open-source Python library for building 3D CAD models

#52
I have written a lot of openSCAD code, I learned about BOSL(2) and wrote even more, I tried getting into build123d (and failed, as running openSCAD/BOSL2 is way too comfortable to leave it)... the only downside is that AI fails horribly with those libs and frameworks.

I think I heard of cadquery before and decided against it, in favor of build123d.

Re: CadQuery is an open-source Python library for building 3D CAD models

#53
Using a coding CLI I was able to create a computed shape would otherwise by incredibly challenging to make (impossible in parametric CAD GUIs at least) LLMs + CadQuery is a powerful combo, this will be more and more common I think. It's just too powerful to ignore.

Re: CadQuery is an open-source Python library for building 3D CAD models

#54
Big fan overall. Designed a tension sensitive winch with this a few years back.

Doing CAD with code seems like obviously the right move to me. The ability to just write new functions in python and do version control with git are super powerful.

The big thing that struck me as innovative with CadQuery is the design intent query part. Selecting model geometry by relation to other geometry is way more resilient to changes ealier in the model's history than the regular "that point right there" you get with just clicking a point.

That the developers acknowledge that seeing the model at various steps in the script is important, and so have the CQ-editor, is also a point in their favour.

I do have a gripe though:

Having to keep all the geometry selection stuff relating to the model in my head is hard. I want gui tools that write code.

Like if I have a complex model, and variables assigned to various parts of the geometry. I want to be able to see that geometry highlighted and labeled, so I know what's easily selectable, and I want to be able to click buttons based on my design intent and get immediate visual feedback, and have each of those button presses added as code as I do them.

Look at this example model: https://cadquery.readthedocs.io/en/latest/examples.html#a-pa...

This bit that selects some points?

  # compute centers for screw holes
  topOfLidCenters = (
    cutlip
    .faces(">Z")
    .workplane(centerOption="CenterOfMass")
    .rect(POSTWIDTH, POSTLENGTH, forConstruction=True)
    .vertices()
  )

Each of those lines should be a gui tool interaction that generates that line of code.

Re: CadQuery is an open-source Python library for building 3D CAD models

#55

Big fan overall. Designed a tension sensitive winch with this a few years back. Doing CAD with code seems like obviously the right move to me. The ability to just write new functions in python and do version control with git are super powerful. The big thing that struck me as innovative with CadQuery is the design intent query part. Selecting model geometry by relation to other geometry is way more resilient to chang…

The OCP CAD Viewer extension for VS Code (works with both CadQuery and build123d) gets partway there - you can click on faces/edges in the 3D view and it shows you the selection info you'd need for your code. It's not full "click to generate code" but it helps a lot with the "keeping geometry in my head" problem. Still a long way from the OnShape FeatureScript model where GUI and code are truly bidirectional though.

Re: CadQuery is an open-source Python library for building 3D CAD models

#56
post #13
post #10

Earlier quoted context omitted.

OpenSCAD is all triangles and vertices. Fillets are difficult to do. Outputting circles/spheres generally requires you to for-loop over vertices a lot. Libraries like build123d and cadquery use OpenCASCADE, a boundary representation kernel. You think in terms of the enclosed solid and perform operations - boolean add/subtract, fillet/chamfer, stamp text, etc - that return a new solid.

I'm not sure I understand your comment; OpenSCAD has functions like sphere(), cylinder(), etc. Most OpenSCAD models I have seen are built up primarily from solid primitives combined using boolean operations, just as you describe for the other tools. https://en.wikibooks.org/w/index.php?title=OpenSCAD_User_Man...

> I'm not sure I understand your comment

Try to do the following with OpenSCAD:

    1. put a sphere and a torus somewhat close to each other
    2. find the shortest segment between the two surfaces
    3. place an infinite cylinder whose axis is aligned with the segment you just found
    4. fillet the cylinder with both the torus and the sphere along its intersection curve with each surface
This is very, very hard to do with OpenSCAD.

Re: CadQuery is an open-source Python library for building 3D CAD models

#57
post #46
post #9

Here's an example! I recently used their sister library (build123d, same devs) to build a rotary slide rule bracelet for multiplying three-digit numbers. It was a great experience and wouldn't generally be easy to do with Fusion 360. My bracelet gets quite a lot of comments when I wear it in public. :-) Here's an IPython notebook with lots of pictures so you can see how the different operations come together: https:/…

> wouldn't generally be easy to do with Fusion 360 Actually... https://www.youtube.com/watch?v=DNiQJyRTs50 You would create the numbers and marks in a vector drawing program (Inkscape, Affinity Studio, Illustrator) and import that into Fusion.

Sure but like, that is specifically NOT easier if you need to iterate once initial implementation is complete. At least in my opinion as an industrial designer turned software engineer, which I only mention to assert I’m experienced in both sets of tools.

Re: CadQuery is an open-source Python library for building 3D CAD models

#58
post #46

Earlier quoted context omitted.

> wouldn't generally be easy to do with Fusion 360 Actually... https://www.youtube.com/watch?v=DNiQJyRTs50 You would create the numbers and marks in a vector drawing program (Inkscape, Affinity Studio, Illustrator) and import that into Fusion.

Sure but like, that is specifically NOT easier if you need to iterate once initial implementation is complete. At least in my opinion as an industrial designer turned software engineer, which I only mention to assert I’m experienced in both sets of tools.

True, the logarithmic scale lends itself to programmatic creation. I just wanted to show that the wrapping part is easy. Actually much easier – that code looks non-trivial.

Re: CadQuery is an open-source Python library for building 3D CAD models

#59
post #8

CadQuery and build123d have been very handy for prototyping stuff for 3d printing. AI still isn't quite good enough to generate correct scripts, but AI autocomplete at least helps with putting together small snippets. My last project involved making a cosplay helmet. I modeled the shell in blender, it was a low poly design, so I exported it to an OBJ, then put together some Python to load the OBJ, give the triangles…

yeah -- have been playing with this as well, ai's spatial reasoning is not quite there yet but with precise construction instructions it can often do the job

for shapes that are hard to print with a traditional slicer, LLMs are also surprisingly good at generating gcode with fullcontrolxyz if you're specific

Re: CadQuery is an open-source Python library for building 3D CAD models

#60
post #50
post #45

Earlier quoted context omitted.

Only step import at the moment. I'll add svg next.

My particular immediate use case would be to export the board outline and mounting holes from a kicad project (SVG or DXF, whatever works) and build a chassis for it. Obviously I can do this in freecad but I've been looking for an intuitive cad-as-code system to check into git instead. So this would be awesome!

While not code as CAD, Dune 3D has the creation of enclosures for electronics projects as its _raison d’être_, and has a facility for Python scripting:

https://docs.dune3d.org/en/latest/python.html

Post reply on HN