Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
CadQuery – a parametric CAD script framework (github.com/dcowden)
41 points by helb on May 14, 2018 | hide | past | favorite | 16 comments


This is awesome!

I’ve been using Python to generate OpenSCAD scripts, and then a half-finished Python binding for OpenSCAD. This framework uses the natural parametric CAD modeling primitives, like the workplane. I never got used to the OpenSCAD way.

I’m switching my stack over to this today.


I'd love to know how this works out for you. I was trying to do something similar, but got stuck.

The core issue is that the fluent object design approach makes it very difficult to decompose objects into reusable features. The shared state behind the fluent approach makes creating multiple sub-objects (to then combining them) difficult (maybe impossible). The power of Python gets limited to thinking about only one thing at a time.

See https://github.com/dcowden/cadquery/issues/167

They are trying to fix this in 2.0, but that's still in early development.


It looks like the problem isn't where I thought it was. Still figuring out how to get it to work, though.


Also check out cqparts which builds on cadquery and add the concept of parts, assemblies and mates to cadquery

https://github.com/fragmuffin/cqparts


Have used the FreeCAD plugin a little bit, useful to create some parts that are hard/tedious to do with visual constraints/operations. However I did struggle a bit with the DSL, think I might be faster if just using the FreeCAD Python API directly...

Jupyter Notebook support is super cool through, will give that a go for generative/data-driven models!


Quick question:

Why would I use this or OpenSCAD instead of Fusion 360 or TinkerCAD?


The other answers don't quite address why you would prefer this specifically versus Fusion 360 or TinkerCAD (or OnShape, SolidWorks etc).

Simple answer: they (cadquery and OpenSCAD) are free and open source. Fusion 360 for example is free for most hobbyist use, but it's still a proprietary package and you're depending on AutoDesk's good will. This has historically been a bad idea, AutoDesk has done the bait-and-switch routine many times and are not exactly benevolent. I genuinely think Fusion 360 is probably the best all-round CAD/CAM package available and it's nice that they currently offer it for free, but I'd be hesitant to really go all-in on using it. AutoDesk could pull the rug out from under free users at any moment, leaving you with the choice of paying up or losing the ability to edit your projects. Or they could go out of business at some point in the future; since Fusion 360 is heavily cloud based that might leave you in quite a pickle (a bigger concern for smaller operations like TinkerCAD).

Free is also important compared to products like SolidWorks, which is priced way outside the price range of most hobbyists. Not to mention, most commercial CAD packages aren't cross platform (with exceptions), while OpenSCAD and CadQuery both run on Linux.

These are not necessarily decisive concerns depending on your priorities, but they are significant. I use both OnShape and Fusion 360, but I also don't really care about long term access to my designs.


There seems to be a plague of vendor schemes attempting to lock up your own designs into their proprietary service.

While there surely are benefits to many classes of uses to having their data accessible via a cloud service, I think the main benefit is getting that recurring revenue on the vendors' balance sheet.


Complex CAD parts can have complex construction to get things like symmetry and parametric sizing to work correctly. It's much more involved than word processing, for example. If you watch an experienced CAD technician work, they will often wipe the entire part and start over so that the right operators are applied at the right part in the construction sequence.

So CAD part design is a lot like programming, so why not use an actual programming language? That way you get the editing and version control of a programming language.

OpenScad works fairly well for 3D printing, but isn't very good for CNC. It's internal engine understands volume occupied, but not surface shape. This means it can't output standard CAD file formats like STEP or IGES.

CadQuery uses the same engine that's in FreeCad to output STEP and IGES files. It's Python based, so you don't have to learn another language to use it. FreeCad or other CAD programs can then do analysis or generate CNC profiles, for example.


I feel like this misses the point of the D in Computer Aided Design.

Engineering and Product design are incredibly visual and collaborative processes that an industry standard CAD package provides the right tools for.

A designer my rough out a component and try it in an assembly, try to explore the ergonomics with human models or the design for manufacture and assembly by exploring it's space claim in respect to the rest of the assembly.

The aesthetics and GUI rendering are also extremely important for exploring where to go with engineering and aesthetic product designs.

Programming itself is incredibly creative, but programming as a CAD tool is, I feel, decidedly antithetic and sterile.


CadQuery is usually used within FreeCAD. Most of what you describe is there because the part just shows up in the CAD workspace like any other part.

The only difference is that you make changes by changing code instead of doing it graphically. In a perfect world, you'd be able to do it either way; but current technology doesn't know how to relate final characteristics back to the line(s) of code that set them.

As parts and their relationship to the whole become more intricate, the programming approach makes more sense.


When the shapes you want/need are hard or tedious to express in say Fusion360 (or FreeCAD, which is same type of software).

As a simple examples, I needed NN concentric circles (plus some details) with increasing radii. In FreeCAD one can easily create linear or radial arrays of NN objects, but not an array where radius increases per instance. I would have had to create all NN instances and position them individual. If N was 4 I'd probably just do that, but not for over 10 - especially because it may change. Note that other graphical CAD softwares might have this particular operation (rotoscale array), but there will always be something which is not available. But 99% of my designs (mostly mechanical parts) are done graphically in FreeCAD. This despite being a programmer, and quite familiar+fond of Python.


When you want to expose a parametric part designer UI. Thingiverse Customizer for instance will let you upload a base OpenScad model, and then let users insert parameters (like sizes) and get out the specialized model on the fly.

EDIT: parametricparts.com supports cadquery I think, http://store.parametricparts.com/cadquery.html


One reason is that you get Revision history, branches etc. using the VCS of your choice. Much more powerful than any PDM system in my opinion


CadQuery is terrible naming... FluentCad or something would have made a lot more sense...


Ya. When they named it jQuery was the new hotness.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: