Remix.run Logo
copirate 5 hours ago

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.

somat 6 minutes ago | parent | next [-]

This is also something I really want, what is the best way to include constraint solvers? I have been messing around with sympy see what insights it provides in this domain, but to actually use it the cad DSL would have to be python, is there an easy way to build a simple constraint solver out of a normal imperative workflow?

deckar01 4 hours ago | parent | prev | next [-]

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

jwagenet 4 hours ago | parent | prev | next [-]

The reality is build123d is a fairly thin layer over the OCCT kernel with some pythonic affordances. I'm not sure OCCT has a robust constraint solver, so there is little development there. FreeCAD on the other hand (besides being significantly more mature) is also build on OCCT, but also does a lot on top of the kernel to make it more featured and stable.

Cargo4286 4 hours ago | parent | prev | next [-]

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

maouida 4 hours ago | parent | prev | next [-]

I'm working on one with features you mentioned, with the main goal to make the workflow similar to mainstream CAD. Will release the first dev version in less than a month.

htgb 4 hours ago | parent | prev | next [-]

build123d has constraints for avoiding math. I'm not familiar with the sketch constraints in FreeCAD though, how do they compare?

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

numbers_guy 4 hours ago | parent | prev [-]

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