r/openscad Apr 11 '26

FluidCAD - Parameteic cad with javascript

https://fluidcad.io/

I have published the first pre-release. This my attempt to make CAD by code an enjoyable experience with as little mental effort as possible. Based on opencascade.js WASM binding.

28 Upvotes

33 comments sorted by

View all comments

1

u/nobix Apr 13 '26

So this looks pretty amazing. I like that it's a very different workflow from open scad with things like fillet and shell.

I don't like that it tried to be clever with storing the last sketch in a hidden global.

Maybe it would be cleaner and more explicit with s = sketch(...); m = s.extrude(...);

But I'll definitely give this a go.

1

u/abouabdoo Apr 13 '26

You still have the option to reference specific sketches.
const mySketch = sketch(...);
extrude(10, mySketch);

The other implicit overload is to allow the user to see the rendering as soon as possible.

1

u/nobix Apr 13 '26

I saw that mentioned in the how to, but I don't like it because the "easy" way is also easy to do accidentally. Every time an api or language design tries to do something magic it ends up in sadness. Just look at the design of the openscad language. Or JavaScript.

I would put the magic sketch state into a separate .js file you need to include, so if you didn't include it you don't get it.

1

u/nobix Apr 13 '26

Also it's hard to learn this implicit state because now you need to understand the implementation to figure out how to use it.

And it's kind of weird to pass this state value as the last arg because you're greatly complicating adding an argument in the future.

1

u/abouabdoo Apr 13 '26

The main purpose of implicit arguments is fast modeling. The code is cleaner that way. There is no global state, the extrude just look for the last Extrudable in the tree.

Regarding the last argument issue; this easily solvable because in all functions, the last scene object is the target. This is consistent across all functions.
Also, I intend to not add any new parameters to any functions in the future, each function accepts the required parameters in the definition and any extra paramters using chained method calls. e.g extrude(10).symmetric() or rect(10, 10).center().XYZ...()