\

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

87 points - last Tuesday at 11:20 PM

Source
  • gcr

    today at 3:25 AM

    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://github.com/gcr/sliderule-bracelet/blob/main/version-...

    build123d is quite different stylistically from cadquery, but this should give you the flavor of programming-oriented CAD at least.

      • today at 4:45 AM

        • aaronbrethorst

          today at 4:07 AM

          how does it work? (the multiplication)

      • hgoel

        today at 3:02 AM

        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 some configurable thickness etc. Then I used it to explore how to print the helmet in such a way that the outer surface would be too clean to tell it's FDM printed, without needing to do any sanding.

        Initially I explored having cadquery put a number on the back of each triangle and I'd assemble it like a puzzle, but that didn't work out. Eventually I figured out how to cut it up into parts that would also eliminate the need for painting and outer surfaces would be clean, and because it was in code, changing which part a triangle belonged to was a matter of moving the corresponding index into another list.

        I probably could've managed it all in blender too, but being much more comfortable with code, it was easier for me to play with normals and manually turning each piece into a solid.

        I also go for it for functional designs because, again, tweaking code is more comfortable to me than dealing with constraints and sketches and multiple planes in, say, FreeCAD.

        • ozmaverick72

          today at 2:16 AM

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

            • gcr

              today at 3:30 AM

              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.

                • 7bees

                  today at 5:38 AM

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

              • DrNefario

                today at 2:19 AM

                CadQuery can export STEP files, and is overall much nicer to use in my opinion.

                  • xrd

                    today at 2:29 AM

                    I've been using Gemini to generate openscad programs for use with my 3d printer. Is cadquery a better option I wonder?

                    Why do you say it is better than openscad?

                      • xrd

                        today at 2:45 AM

                        After reading some of the docs it does look fun.

                        Python, so leverage your Python skills and existing libraries.

                        A nice GUI so you can build, view, tweak, review, iterate.

                        Will be a nice new toy...

            • colechristensen

              today at 2:51 AM

              Neat!

              I'm working on a CAD kernel in Rust with a frontend either as a Blender plugin or a Blender fork (leaning towards fork at this point) It's not at all ready but I have reached first part status (before going back and rewriting a large chunk of the kernel)

              • kevinten10

                today at 2:30 AM

                [dead]