My pet use case is: "My naive approach as a programmer would be: pen := new Pen(q,r,s,t); box := new Box( pen.L, pen.W, pen.H )" along with being able to sometimes work with the whole pen, and sometimes touch the pen vs. the cap separately.
Since it's all javascript, it seems like there's a chance that this use case would work (ie: p = Pen(...).render().getWidth())? Additionally, your intermediate step screenshots really makes it seem like a SketchUp-ish GUI would be perfect! Obviously a ton of work, but SketchUp's "grab face + extrude / push", but if it were "sticky" to the underlying parametric components seems like it'd be an awesome combo... something like group/components, but backed by code instead of GUI-only (or GUI-centric) editing.
The interactive region extrude feature is designed specifically for fast modeling at the expense of making the model "not so parametric". When user pick a region, the raycasted point is inserted/hardcoded in the code. e.g extrude(100).pick([100, 100])
So if the sketch dimensions change, there is a chance the point will fall outside the region boundaries which will break it.
It is preferred to use proper boolean operations in sketch mode to define regions while keeping it parametric.
The interactive region extrude is there for when you want fast modeling/prototyping.
These code base cad systems are pretty great. But all of them are imperative languages and as such can only solve imperative constraints. Including declarative constraints would be very welcome. I mean, sure, Theoretically we could enter the turing tarpit and build our own constraint solver, but it would be nice to see one included as a standard library.
I am trying to think of an example, declarative constraints are usually the domain of a graphical cad system(like solvespace). but I suspect it would look like a set of relationships you can enter in any order and it solves for the missing one. so... prolog? has there ever been a cad system in prolog?
The constraints solving took a good amount of thinking while designing FluidCAD. At first I tried to make it all declarative where user just create unconstrained geometries then define constraints, something like:
const l1 = line();
const c1 = circle();
// define constraint
l1.length(100).position(x, y).tangentTo(c1)
...
Then I decided against this idea because it results in too much typing + the constraint solver implementation is not trivial and there is not much web based open source solvers. I went with a mixed approach instead between declarative and imperative. https://fluidcad.io/docs/guides/sketching/constrained-geomet...
I've been revisiting OpenSCAD recently but find it very frustrating. I just got started with build123d which is great but I'll definitely be trying this. The workflow is exactly what I'm looking for.
I'll drop an issue if I have feedback. Are you open to PRs?
I've been using OpenSCAD and Build123D so far, but OpenSCAD is limited and Build123D is Python and I'd much rather use JS/TS.
Just curious – when when you do a sketch and then call extrude, why the implicit connection there? Why not assign the sketch to a const and then do s.extrude?
Looks great! Nice work.
I am steeped in CAD for my work flow, so I used to program AutoCAD in AutoLISP, Rhino in Rhinoscript, now F#, and FreeCAD in Python as well as Blender. They have the geometry engines built-in and tested over decades. I think this is good for the maker with a 3D printer to do parts that are relatively simple (not discounting parametric code to make complex shapes here). Industry needs integration of CAD, BIM, CAM, Viz, etc. Take a look at this now older (2014) project where Rhino and F# were used to design and manufacture complex geometry for a real world build: https://www.youtube.com/watch?v=ZY-bvZZZZnE
The thing that made Flash magical was that it had the approachability of a design tool (and it really did have some of the best design tools ever), with the extensibility of a scripting language. You could start by drawing on a canvas and grow into programmatically generating designs.
This looks like it could do the same thing for constraint modeling. That's awesome!
This is nice, though I think the use of indices instead of stable identifiers might bite in complex models that undergo changes. I've been toying with the idea that you could specify a point (2D or 3D in some coordinate system, depending on context) and pick the face/edge/point closest to that as the identifier. The only other alternative I see is diffing old and new, and trying to match the outputs of each operation geometrically, but that would produce extra output that needs to be persisted...
E.g. when splitting a face in OnShape, I might have to redo a whole bunch of operations later because the identifiers change, but I'm often surprised how good it is at matching up faces after a single operation. Like modifying a sketch, then having to add the new face to an extrusion, but then it magically does the right thing for chamfers and drafts.
Yep, topological naming solving is a hard problem to solve. It took FreeCAD many years to get it to work correctly. That's why I went with indices for this version. You can also use filters like extrusion.endFaces(face().arc()) to get only arc edges.
When the user click on a region we insert a 2D point, then the extrude feature will find the nearest face.
I have experimented with adding this picking logic to selections too select().pick() which will probably be merged in future releases.
Really interesting! Love the combination of 'code cad' and graphical interface. I've been screwing around with build123d and its vscode plugin, which always selections, but this seems to take that concept much further.
One obvious difference I can see at a glance is that Maker.js doesn't support 3D models, while FluidCAD does. I assume Maker.js is a lower level library aimed at interfacing directly with CNC machines, while FluidCAD is focused on 3D design.
This looks great. I just started trying to generate some models using golang and the ecosystem doesn't seem great. Will check this out, might work out better.
38 comments
https://github.com/openscad/openscad/pull/4478#issuecomment-...
My pet use case is: "My naive approach as a programmer would be:
pen := new Pen(q,r,s,t); box := new Box( pen.L, pen.W, pen.H )" along with being able to sometimes work with the whole pen, and sometimes touch the pen vs. the cap separately.Since it's all javascript, it seems like there's a chance that this use case would work (ie:
p = Pen(...).render().getWidth())? Additionally, your intermediate step screenshots really makes it seem like a SketchUp-ish GUI would be perfect! Obviously a ton of work, but SketchUp's "grab face + extrude / push", but if it were "sticky" to the underlying parametric components seems like it'd be an awesome combo... something like group/components, but backed by code instead of GUI-only (or GUI-centric) editing.The interactive region extrude is there for when you want fast modeling/prototyping.
I am trying to think of an example, declarative constraints are usually the domain of a graphical cad system(like solvespace). but I suspect it would look like a set of relationships you can enter in any order and it solves for the missing one. so... prolog? has there ever been a cad system in prolog?
Then I decided against this idea because it results in too much typing + the constraint solver implementation is not trivial and there is not much web based open source solvers. I went with a mixed approach instead between declarative and imperative. https://fluidcad.io/docs/guides/sketching/constrained-geomet...
I've been revisiting OpenSCAD recently but find it very frustrating. I just got started with build123d which is great but I'll definitely be trying this. The workflow is exactly what I'm looking for.
I'll drop an issue if I have feedback. Are you open to PRs?
I've been using OpenSCAD and Build123D so far, but OpenSCAD is limited and Build123D is Python and I'd much rather use JS/TS.
Just curious – when when you do a sketch and then call extrude, why the implicit connection there? Why not assign the sketch to a const and then do
s.extrude?Great work so far!
This looks like it could do the same thing for constraint modeling. That's awesome!
E.g. when splitting a face in OnShape, I might have to redo a whole bunch of operations later because the identifiers change, but I'm often surprised how good it is at matching up faces after a single operation. Like modifying a sketch, then having to add the new face to an extrusion, but then it magically does the right thing for chamfers and drafts.
Regarding the picking; that's exactly the region picking feature in this screenshot: https://fluidcad.io/img/region-extrude.gif
When the user click on a region we insert a 2D point, then the extrude feature will find the nearest face. I have experimented with adding this picking logic to selections too select().pick() which will probably be merged in future releases.
Irrespective - This project is pretty cool to see!
[1] https://en.wikipedia.org/wiki/AutoLISP
https://www.microsoft.com/en-us/garage/profiles/maker-js/
Which operations are supported? (Booleans? ...)
Where's the API link?
...finally, was this vibe-coded?
Inquiring minds want to know!