Live data from Hacker News

Build123d: A Python CAD programming library

github.com

31–40 of 67 posts

Re: Build123d: A Python CAD programming library

#31
post #16
post #2

These types of CAD scripting tools are great but always try to position themselves as an “alternative” to GUI-driven CAD, whereas in reality they are complementary. OnShape got it right with FeatureScript ( https://cad.onshape.com/FsDoc/ ), which provides a very similar experience to Build123d at the scripting level. However, the insight that OnShape got right is that these scripts automatically become available as p…

I think most GUI CADs have some kind of API like this. In FreeCAD it's Python. In Solidworks, it's VBA or C#. I don't think any are particularly well documented or supported by tutorials.

Solidworks has VBA macros, which (on top of being poorly documented and unstable) subvert to the whole benefit of parametric CAD. Once you're creating features with a macro, you naturally want to edit them, but you also naturally want to rerun the macro itself to create them differently. It's like editing generated code and it's not a viable long-term setup.

FeatureScript is a different beast. It actually runs as part of regeneration in Onshape. Standard features (extrude, loft...) are also defined in FeatureScript, so your custom features are the same first-class citizens with a interactive GUIs and stable updates to upstream changes. You can freely mix interactive CAD and custom code by adding standard features and custom features.

Re: Build123d: A Python CAD programming library

#32

Why do these tools never have the equivalent of sketch contraints in FreeCAD? That's how I build my models and it avoids a lot of math. I'd really like a "CAD as code" tool that's basically the FreeCAD Part Design workflow but with code. I know FreeCAD has a python interface but it's far from developer friendly.

FreeCAD has a Python API that you can use to too. It's their "macro" functionality.

Re: Build123d: A Python CAD programming library

#33

Why do these tools never have the equivalent of sketch contraints in FreeCAD? That's how I build my models and it avoids a lot of math. I'd really like a "CAD as code" tool that's basically the FreeCAD Part Design workflow but with code. I know FreeCAD has a python interface but it's far from developer friendly.

Also worth looking at this project https://gitlab.com/dmytrylk/solve123d which adds constraints on top of build123d using a jax-based numerical solver.

Re: Build123d: A Python CAD programming library

#34
post #14
post #2

These types of CAD scripting tools are great but always try to position themselves as an “alternative” to GUI-driven CAD, whereas in reality they are complementary. OnShape got it right with FeatureScript ( https://cad.onshape.com/FsDoc/ ), which provides a very similar experience to Build123d at the scripting level. However, the insight that OnShape got right is that these scripts automatically become available as p…

I’d love to see this. It was a frustrating learning curve for me to realize that I couldn’t STEP export work from OpenSCAD to something like Fusion. Build123d is much better (supports STEP export and import) but a tightly integrated CAD frontend would be ideal!

PythonSCAD now has STEP export:

https://github.com/pythonscad/pythonscad

Re: Build123d: A Python CAD programming library

#35

Why do these tools never have the equivalent of sketch contraints in FreeCAD? That's how I build my models and it avoids a lot of math. I'd really like a "CAD as code" tool that's basically the FreeCAD Part Design workflow but with code. I know FreeCAD has a python interface but it's far from developer friendly.

It has constraints, it just doesn’t have a declarative constraint solver.

https://build123d.readthedocs.io/en/latest/tutorial_constrai...

Traditionally CAD programs require declaring geometry, then defining constraint relationships between them. That leaves ambiguity. I often create under-constrained sketches in Fusion, then change a dimension, which breaks the geometry in ways that technically respect the constraints.

They designed an imperative constraint system. A lot of constraints are linear, so you can just order the sketches and reference as needed. For circular or bi-directional references you probably have to define some construction geometry first, solve the constrains there, and reference it.

Something I haven’t seen before is their filter syntax for disambiguating solutions. You can express how the desired solution relates to the surrounding geometry. This constrains correctly across large parameter changes and will error when there is no longer a solution rather than switching to an unexpected solution to the constraint.

https://build123d.readthedocs.io/en/latest/tutorial_constrai...

Re: Build123d: A Python CAD programming library

#36
post #20

I used to do a lot with AutoLisp in AutoCAD back when it ran in DOS. Did a lot of dynamic creation and manipulation of the models with it. It was useful and a lot of fun (aside from parenthesis nesting).

I did that back in the 90s too. A modern IDE like set of features for lisp would've been awesome. Notepad on NT4 didn't cut it :)

Re: Build123d: A Python CAD programming library

#37
post #20

I used to do a lot with AutoLisp in AutoCAD back when it ran in DOS. Did a lot of dynamic creation and manipulation of the models with it. It was useful and a lot of fun (aside from parenthesis nesting).

I use a scheme variant in an optics simulation product.

It's actually very pleasing to work with. I wish there was more stuff like this. Lispy programming languages and CAD seems like a natural fit.

That said, python is preferable for most people.

Re: Build123d: A Python CAD programming library

#38

Earlier quoted context omitted.

I disagree. Most CAD is inherently visual. These code-based systems work great for highly parametric and regular objects like fasteners and gears, or for procedural art, but those are really the tiny minority of CAD tasks. Most of the time you need to see what you're doing and click on stuff. Most CAD is more similar to graphic design, painting, etc. You wouldn't expect a "code first workflow" for Illustrator, and as…

[flagged]

Yeah that would be amazing, but sadly nobody has made that work for any CAD of reasonable complexity.

In reality, CAD version control is done just like assets in the artistic world (game design, animation, films, etc): with file locks.

I used to work for Dyson. There's no way you're designing a vacuum cleaner with code-based CAD. We used TeamCenter (which is probably the worst software I've ever used, but for unrelated reasons).

Re: Build123d: A Python CAD programming library

#39
post #6

I have been using this library for a few months alongside Gemini 3.1 Fast It's really useful to get an iteration loop going with an LLM. The OCCP viewer extension for VS Code helps make sure you can see and manipulate the resulting model

last time i tried, i didnt get the standalone mode to run.. there seems to have been an update in february, so i will give this another try when there's time.. (context: https://github.com/bernhard-42/vscode-ocp-cad-viewer/ )

data point: standalone mode worked just fine for me a couple of weeks ago on an M4 MBP. Hadn't tried before so can't say if something got fixed.

Re: Build123d: A Python CAD programming library

#40

Earlier quoted context omitted.

[flagged]

Yeah that would be amazing, but sadly nobody has made that work for any CAD of reasonable complexity. In reality, CAD version control is done just like assets in the artistic world (game design, animation, films, etc): with file locks. I used to work for Dyson. There's no way you're designing a vacuum cleaner with code-based CAD. We used TeamCenter (which is probably the worst software I've ever used, but for unrelat…

I mean, the CAD software, even though visual, has to retain some internal state of the model, right?

It's possible, but I don't think there's enough pressure for these companies to support exposing that state to the user.

Post reply on HN