CAD Sketcher, free and open-source project bringing CAD like tools to Blender3d
cadsketcher.com
cadsketcher.com
The most widely used kernel is OpenCascade, the kernel used by FreeCad. However it is outdated, unstable and limited in significant ways with no realistic future prospects. It is unfortunately the limiting factor of FreeCads functionality and prevents any serious use of it.
The most widely used commercial kernel is Parasolid, used in many packages including SolidWorks, OnSpace, and NX.
What I would love to see is Siemens adopting a model similar to some of the game engines (Unreal and Unity) where it's free up until a revenue limit. Opening up Parasolid for "free" open source and small commercial operations would be both brilliant for society but also for Siemens, it would only result in a growth in the use of Parasolid and increased revenue.
The ideals of free software though call to produce free and open code because it remains free, open, and available. Siemens, were it to graciously offer some free tier access, would be also in a position to limit or withdraw such access at any moment. (This even applies to the paid licenses.)
However limited OpenCascade is, it's here, and it's usable, up to a point. I hope that a successor to it will emerge, if there's a need.
I've seen people quote a good modern CAD kernal as a 100 man year project. It's probably not going to happen, maybe there's some avenue for government funding?
Alternatively Signed-Distance-Functions are pretty nice. They're not BREP, but they're a lot easier to implement, and it might be possible to shove them into a BREP-shaped hole.
Here's a signed-distance-function based CAD kernal written in a few thousand lines of python+numpy, that seems to be about as fast as openscad. Maybe faster. https://github.com/fogleman/sdf
I suspect that having a generic meshing algorithm that will always mesh your datastructure with no edge cases would significantly reduce the time needed to implement a CAD kernel. You just need an algorithm that can tell you if a given point is inside or outside of your BREP. All you really need for that is a surface that points at a given direction, and the ability to tell whether a point is under the surface or not. Define your surfaces as BREP, render them using SDF, only have to write one meshing algorithm.
That being said I disagree with your definition for parametric CAD. Mostly the name, I get that you're talking about BREP based CAD. That is one way to do parametric CAD, but CSG can also work, especially if you can do more advanced operations like a filleted difference or union, or blends between two shapes, or other advanced CSG operations. I don't think that CSG-based CAD is inherently worse as long as you've got the ability to do things like fillet/chamfer CSG operations.
You probably don't need to do a fillet along an edge if you can do a fillet where you subtract one object from another, something that SDFs can do easily: https://github.com/fogleman/sdf#smooth_difference
That said, you can e.g. calculate derivatives of the SDF and, simply speaking, when they 'flip' you know you found an edge or corner. You can project onto the SDF along a plane or line and 'record' the intersection, use it as input in your model etc.
Similarly, you can treat an area bounded by such edges as a face etc.
Just because there is nothing out there yet doesn't mean it can't be done.
I also predict a great future for SDF based CAD for the simple reason that manufacturing methods mostly used for prototyping now (3D printing) will become more common for final pieces.
And there is no need for an explicit representation (higher order surfaces or polygon meshes) of the shape to get tool paths (often derived from 2D bitmap slices) for these methods.
I'd argue that this information is becoming even more important with the rise of 3d printing and other digital manufacturing tools. If this information can be included in the CAD data, the manufacturing tool might automatically determine how best to manufacture the part to meet the required tolerances.
Topological information is also useful for analysis. We may wish to apply a load or boundary condition only on a face.
> I've seen people quote a good modern CAD kernal as a 100 man year project. It's probably not going to happen, maybe there's some avenue for government funding?
Perhaps the leverage of AI coding assistants will bring it down to a few man years over the next 5.
SDF do seem like a cool option. They’re computationally expensive but I’d bet the ray tracing features coming out in GPUs would help with that.
In my uninformed opinion working with meshes is hard. In the interest of comparing apples to apples I'll compare a CSG-based approach (joining two mesh objects together) with an SDF-based approach (joining to SDF objects together).
If you want to merge two mesh spheres together you need to do a lot of work. First you need some way of telling whether a point is inside or outside of another mesh. This is because you need to be able to delete all the vertexes/points/faces that are inside the other mesh. So you do that, and you delete all the points/vertexes/faces that are colliding with the insides of another object. Then you need to stitch the two meshes together. This is a whole thing, you need to find the boundary where the two meshes would have collided, create a bunch of new edges along that path while also taking into account where the existing faces on both objects are going to be.
There's a lot that can go wrong during this as well, it's possible for your geometry to be "non-manifold" which means it has no clear inside or outside, and it's really easy to accidentally make an object non-manifold when you're stitching it together with another object. There are issues where sometimes meshes look alright but in reality there are two edges on top of each other, or a face with zero area, or all kinds of crazy stuff. Making a tool that can reliably stitch two meshes together is a pretty big challenge. Than you start talking about adding fillets to vertexes, and how that affects the mesh geometry of other attached faces, and you're having to write some really complicated error prone code for N different combinations of situations. Like what if the chamfer abuts another chamfer? What if it abuts a spheroid? A bunch of edge cases (heh) depending on the faces that your edge butts up against.
With SDFs you just check if the point is inside one object or the other, and than re-generate the mesh from scratch. You write one not-too-difficult mesh algorithm and everything else is basically just OR/XOR/AND-ing things together. It makes defining geometry geometry about as simple as possible, just write a function that can say whether a point is inside your geometry or not. Something you need to be able to do for mesh based CSG anyway, but with a bunch more complications.
This is also why tools like openscad can't do fillet/chamfer joins after 10 years and the tool I threw together in a few weeks can.
One approach would be to construct one solid SDF object out of a bunch of 2D SDF object segements: https://iquilezles.org/articles/distfunctions2d/
The "Parabola Segment - exact" and "Polygon - exact" examples in particular. Probably requires some combination of the two for your use case. Basically turn your lines into 2D SDF objects that define the outside of your object.
I think most of those objects actually could be chained together, like the actual quadratic bezier example has a real interior and exterior when you look at it more closely: https://www.shadertoy.com/view/MlKcDD
So yeah, the intersection of a bunch of line segment SDFs like that could do it. A bit more completed than that but that's the basic principle. Not sure about the performance... There is probably a more efficient way to do it, but I don't have the math skills to figure it out.
My personal idea for how I’d engineer for that is to reframe the problem as “the geometry is a program in a programming language”, and have ways to calculate surface Normals, derivatives, etc.
But you are absolutely correct that choice of representation / data structure makes a huge difference in what’s easy to calculate. And perhaps the best approach would be to internally have tools that can map between different data structure representations based on the calculations on the calculation at hand
Where Fabrice Bellard when you need him? :)
Onshape is an amazing tool. Can't recommend it enough
As you say it's to early to judge but I like that the Fornjot author publishes regular updates on his progress.
I've used Parasolid in a previous job. OpenCascade may be unstable and limited, but Parasolid can be too depending on your use case. Its not a silver bullet.
Works quite well on modern CPUs, works very well on modern GPUs. The library I linked to uses numpy and numpy is fast on CPU, but a newer tool like jax would let you run pretty similar code on the GPU even faster. All this machine learning stuff actually makes python a very good choice for complicated numerical stuff like CAD.
When I say "works quite well on GPUs" I mean "runs in real-time on a shader in a web browser" https://www.shadertoy.com/playlist/43cXRl . Note that none of those objects are meshes, it's a shader rendering the objects directly based on a signed-distance-function, every single frame.
You still need to turn your SDF/point-cloud into a mesh, but that means you only need to implement one algorithm, something like marching cubes is good enough and dual contouring is a bit more complicated but also more precise.
I am a robotics engineer and 100% of my work is open source (see my profile). I understand that without fully open source CAD it is hard to make fully open source machines.
If we were somehow able to rally support around a single project to create an open source CAD kernel and associated interface (perhaps built in to blender or FreeCAD to avoid building a new UI), what approach would you recommend? How long would you estimate it would take for three full time senior developers to get a useful system out?
Any thoughts are appreciated. I am at the extremely early stages in my career where I hope to learn to raise money for open source non profit hardware projects. Open source CAD is a sort of linchpin and without it we cannot succeed in quite the way we would like.
I think so, but there are some open problems. Also it depends on the senior people. Inigo Quilez is a world class expert in this domain, and for the most part we're copying his work, get him on board and you'll be golden.
Fundamentally it makes sense, BREP is about representing boundaries and you can definitely use SDFs to represent the area under a boundary (infinite SDFs are possible, although obviously you can't turn them in to a mesh). Enclose a volume with boundaries and you can mesh that out just fine. A bit different from CSG-based SDFs, but entirely plausible.
>what approach would you recommend?
If I was to do this I'd take the constraint solver from solvespace (same one used in this post) and start using it to generate SDFs. At that point you're already 80% of the way to your end goal.
I mean if I was personally to do this I'd start by making a system that implements everything openscad can do, try to get some funding going, and than add in a solvespace based workbench for doing 2D cad that you can import into an openscad-ish language. You can see my efforts here: https://github.com/traverseda/PySdfScad
That's tackling it from a different angle than BREP though. I think that openscad but better is a surprisingly viable thing though, especially if you use it to do things like generate the gears/screws/whatever you import into your BREP based CAD project. Use scriptable CAD as the underpinning for more advances CAD.
> How long would you estimate it would take for three full time senior developers to get a useful system out?
Well define "useful"? Honestly I think you can get 80% done in under a month. I built the first pysdfscad in a week or two and replicated 80% of openscad's features. Fogleman built the library I used for pysdfscad in under a month.
I'd expect something pretty good in under a year at that kind of rate. There would be some outstanding problems, like it would be a challenge to figure out how to apply a fillet/chamfer to an edge, but not an insurmountable challenge. Geometry import is another place where you're going to spend a lot of time/money but is very important.
So let's say two or three years with three very competent seniors working on it to get a pretty good CAD program, with a GUI.
It would be cool to put together some kind of foundation, with a working group and some kind of RFC process, to build a concrete plan which could then be used for fundraising.
Blender has its purposes, but I think surface or solid CAD must be pretty far down the roadmap. But there are often times where BREP or NURBS type workflows would be quite useful, and also some modeling operations such as "extend geometry from object A based on object B's coordinates and normals" can be very useful.
If you need operations like variable radius fillets on tapered multiple intersections with G3 continuity—this is probably not for that. But selecting the midpoint edge of some other object and offsetting a plane by some radius? This makes that sooooo much easier.
> Blender has its purposes, but I think surface or solid CAD must be pretty far down the roadmap.
As a workaround, here is a free "Export IGES" addon for Blender, which could convert polygonal model into solid/surface CAD file format.
[0] https://www.digital-sculptors.com/cms/index.php/software/ble...
[1] https://blenderartists.org/t/blender-add-on-export-to-iges/1...
I guess fillets are probably one of the most complex things for a CAD tool to support.
Sorry, I work on Solvespace and can confirm it has some serious NURBS bugs. There are several open issues on github relating to NURBS boolean failures. The problems seem to fall into 4 or 5 categories, and we can probably fix some of the common ones. It's going to take time and some deep dives into the code though.
(For not too complex shapes) Its possible to create Fillets/Chamfers in SolvSpace by "by hands".[0,1,2,3,4,5]
[0] https://fosstodon.org/@app4soft/109740222184364152
[1] https://github.com/Symbian9/SolveSpace-Daily-Engineering/iss...
[2] https://twitter.com/app4soft/status/1423871556397244421
[3] https://fosstodon.org/@app4soft/109812747058078617
Why? I've gotten far enough with FreeCAD despite its annoyances that I would be tempted to look into solving the problems with the kernel, and here you are discouraging people like me from getting involved by saying it's hopeless.
The culture of constantly losing interest and starting over in many areas of software is one of the things I dislike the most.
But I don't fight the tide.
I also realized during that time that my distro was doing a poor job at packaging it to make it work as designed (and I can't fault the packagers for that, it's a highly specialized/niche application after all). The flatpak version seem much more cohesive.
If one thing, I'm amazed by how much one can accomplish with FreeCAD given a little patience and perseverance: it brings parametric CAD, drawing projections FEM… to the masses, which, when I was learning that stuff as part of my curriculum, was completely out of reach of most universities, let alone the hobbyist scene.
It's an under-appreciated, fundamental, piece of software if you ask me.
FEA is tantalizing, but I haven't been able to accomplish much yet.
That project has come to an end prematurely. Is there a real future in CAD programming? I feel like I've wasted a good chunk of my life on a dead language in a dead product. Is any of this knowledge portable?
The first one, Truck[1] seems to have a company behind it, Ricos Ltd, that look like they to know what they're doing[2]. The tweet shows their product using functionality from Truck (the frontend is not OSS AFAIK).
Fornjot is an ambitious project IMHO. Their kernel is in a separate crate[3].
As for OSS code that could be a good base to either use (or port to something like Rust) for someone to write their own kernel is Ayam [4], the oldest OSS 3D NURBS modeler that is still being developed.
[1] https://github.com/ricosjp/truck
[2] https://twitter.com/RICOS_ltd/status/1550390552482693120
I suggested that I might support this if Parasolid was made open source, dual licence it as commercial and AGPL, got nowhere with the project leader who is being paid by Siemens.
I known my way around CAD software and so I gave this a shot around 4 months ago, but it looked frankly alien and relied a lot on blender idiosyncrasies and baggage that most people with a CAD background would likely be missing. Basic things were hard to find and simple things were hard to do. I also had doubts that the foundations are sound (whatever engine props this up seems to be using floating point numbers instead of parametric equations, so things like pockets on top of coincident lines would incorrectly leave infinitesimal volumes of material).
I should give it a new look but the road ahead will likely be very long.
This may make me look at Blender again (too hard to learn at the time). Designspark Mechanical isn't too bad if you have become an F360 refugee.
Don't get me wrong, I am not a big fan of it, but it does (mostly) work.
With basic access you can still: View projects Comment on and mark up files Download files
It used to be you had to switch every year. But the ts and cs are buried on the web site if they are public at all. You have have it installed to see your license details, which I no longer do.
F360 locks teams and some features (stress/strength modeling, for example) behind a paywall but for the actual free tier--useful for 3D printing, woodworking, etc.--is effectively unlimited for single-user use. (You have a limit of ten "editable" documents at once, which is silly but not of much consequence.)
Shannon McGarry <shannon.m.mcgarry@autodeskcommunications.com> Unsubscribe Fri, Nov 11, 2022, 7:19 AM
Trial expired: What to do next... Inbox
Shannon McGarry <shannon.m.mcgarry@autodeskcommunications.com> Unsubscribe Sat, Dec 10, 2022, 11:30 AM
My point being, each software has its own mechanics and takes a while to become productive at it. Blender has a lot of content online from users, with tips and tutorials, so it’s currently a good space to be, learning wise.
CAD support is lacking though. Glad linking CAD Sketcher here found more users willing to try it out. Hopefully it gets feedback/support, helping to its development.
Thanks
I'm sure CAD Sketcher will grow a ton of convenient shortcuts too, I don't think they'll have much in common with the rest of blender.
FreeCAD is like entering values into a form, while Blender is like playing around with the model interactively. You can drag anything around, tear it apart, fix it again. It's possible to keep things editable, almost parametric, but this requires more planning and knowledge.
For getting started you definitely want to follow tutorials. One for basic mesh modelling, and one with focus on CAD. (How on earth are you supposed to figure out that you want a "subdivision surface" modifier. It's the first thing I add in every project.) But I'm thinking now FreeCAD may be just as hard to learn as Blender (unless you already know CAD).
(But now that I know the basics of CAD workflows, CAD Sketcher looks interesting. Before that, I wouldn't have seen the point.)
You should try solvespace, it has that fun feel but let's you apply constraints directly on the sketch.
This is really nice, a proper solver
So you get a really good solver and a really good 3D engine
Anything beyond simple polyhedra and booleans runs into a problem. Fillets, chamfers, sweeps and lofts don't work well. It's a shame.
My biggest gripe with freecad isn't necessarily that (it's easy enough to work around), but that going back few steps to edit things and apply it forward is very fragile. There are ideas floating around to better handle this workflow but we'll have to see how well that goes (it's probably a very difficult problem to solve with no general solution). In the meantime this gives me a lot of frustration and rework, but, running on Linux, there's no real alternative as far as I can see.
You make a base sketch and pad it up to create a square part with a single hole in the centre. You chamfer the hole. You change the base sketch so that it is now a rectangular part with 2 holes, 1 at the left and 1 at the right.
Should the chamfer apply to the left hole, the right hole, or both holes?
Obviously there are special cases that FreeCAD doesn't currently handle optimally, but a general solution is impossible without FreeCAD reading your mind.
(You could also asy "any of those 3 options is better than trying to apply the chamfer to a random bit of un-chamferable geometry". But a general solution is still impossible.).
Any changes to the first hole only apply to the first hole, unless that second hole is a linked copy of the first.
____
Is there an argument against this general solution?
IIRC (not testing now) FreeCAD already handles this example sensibly. You can add circles to the sketch and the chamfer stays put. If you delete the circle and add a new one, it appears on the new hole. But if you add a square instead, it moves to a random edge of the rectangular hole.
The 'edge' of the rectangular hole is actually a loop of four edges, so this is understandable. Commercial software can fix some of these cases - I don't think the Freecad link branch can, but it does at least detect that the original geometry was deleted and raises an error asking you to reselect instead of allowing things to move around. And unrelated features downstream don't break. Not dissimilar UX to when I mess with something that Fusion can't handle, I say.
I'm not even sure FreeCAD's editing model is anything like that (on the surface it seems that it understands geometries but disregards the process to obtain them).
Changing the hole from a circle to a square on mainline will completely screw things up though.
The goal of a well-written program is to give the user the opportunity to express what is in their mind at an appropriate time, and to change their mind after seeing some output. And to be told explicitly or implicitly why their inputs don't work.
FreeCAD tends to get wedged so you can't back up, very unpredictably (for a newbie). This makes all its other issues worse because it inhibits experimentation.
It's a lot of work, but often less work than starting from scratch.
What I mean is when you start getting errors that say things are invalid and every time you try to correct it flips to another window/tab.
Even that wouldn't be so bad if you could reliably undo out of it.
When you move things around and break stuff, let's say by creating two disconnected solids, then I would expect a preview to show that.
Also, one problem with FreeCAD is that you need to open a sketch to modify it but often the model you are modifying is then hidden. So now you have to roughly guess the optimal value, close the sketch and inspect the model and repeat this process until you have something usable. If you need to use clipping planes to see inside the model then enjoy setting those up every iteration.
Geometric nodes are great too.
I had to disburse some cash, but I've been complementing Blender with Rhino 3D for a few months now and it's a good mix. Blender is amazing for meshes and renders and animations, Rhino 3D is an amazing BRep modeller and both Grasshopper and Kangaroo 2 help in "getting just the right look".