CadQuery Constraints: Friend or Foe?

Dreaming about cars I can’t buy was fun but now it’s back to study time. I’ve got CadQuery + Jupyter set up and ran through its quick start tutorial. I think there’s a lot of promise in CadQuery and plan to invest time to climb its learning curve. Before I roll up my sleeves and dive in, though, I skimmed ahead to check a few features, the biggest one being constraints.

Specifying constraints in CAD is a concept that is almost as old as CAD itself. It is an important tool for a part designer to embed intent into a design ensuring future changes will not deviate from original intent. The ideal target for a design is to be fully constrained. An under-constrained design is ambiguous because it means some attribute can change without violating specifications, and that is rarely desirable. An over-constrained design is an impossible contradiction that needs to be resolved, a task that can be frustrating if a CAD tool fails to provide sufficient feedback. Such frustration can drive people (me) away from certain tools (FreeCAD) to seek out others (CadQuery).

When I explored the world of code-based CAD earlier, I had no luck finding ways to specify constraints or provide tools to resolve constraints. I inferred this to mean that they’ve left constraints to be specified in our code. Want to constrain a line to be tangential to an arc? Calculate their intersection point in your own code and use that point. The upside is that we have full control, the downside is a lot of duplicate effort repeating common constraint-solving tasks.

The good news is that CadQuery doesn’t drop constraints in our lap as our responsibility. Or at least, it has ambition to handle constraints. I found a page discussing sketch constraints (addressing the arc+line tangent example above) but with a disclaimer the feature is still experimental in development. There are also ways to specify constraints in multi-part assemblies, which seem to be a counterpart to Onshape mates that I’ve used to specify relationship between Sawppy parts.

It looks good on paper! But then, FreeCAD looked good on paper as well. I won’t know if CadQuery constraints will be my friend or foe until I get deeper into learning it, but I wanted to know it at least existed before I got too deep into CadQuery. For now I’m still working to get basic tools up and running.

Leave a comment