CadQuery Quick Start in Jupyter

After a few unproductive FreeCAD sessions where I spent most of my time trying to understand uninformative error messages, I decided I need to take a break from banging my head against that particular brick wall and look at something else. When I had performed a brief survey of open-source CAD solutions, I only scratched the surface of CadQuery because I had managed to catch it at an awkward stage. At the time most of Python ecosystem have moved to 3.11 but CadQuery had not done so yet. Most critically, I wanted the Jupyter interface and it would not be possible until the version support lines up between those two pieces of software.

In the time since my survey, this problem has been resolved and I could play with CadQuery in a Jupyter notebook. I tried to get the default GUI CQ-editor running just for the sake of looking it over, but I had no luck running it. I would start the executable, I could see an application process running, but no GUI ever showed up on screen. Shrug. I doubt I would have used it anyway because I like the concept of doing CadQuery in Jupyter.

A big advantage I see in code-based CAD is the ability to add code comments in between operations, describing the high-level intent behind the actual code statements. Commenting individual operations is not practical in GUI-based CAD tools like Onshape or FreeCAD. Furthermore, while I could enter comment text with Python comment syntax in CQ-editor, a Jupyter notebook offers significantly more documentation capabilities. As I understand it, it’s literally the difference between plain text and markdown.

While CadQuery’s quick start tutorial was written for a beginner to follow along in CQ-editor, my failure to get CQ-editor running meant I had to convert instructions to Jupyter on the fly. My biggest light bulb moment was realizing I could call display(result) at multiple points in my Jupyter notebook. This gives me a snapshot of the current incomplete state, every time I called display(result). So anyone reading the notebook (like me, 6 months from now) could visually see how the object evolved into its final form. I like where this is going.

Leave a comment