3 ms·
The problem CAD as code doesn't easily solve is how to refer to parts of the generated model for further processing. Consider adding in fillets to parts of your
by injidup 5y ago
The problem CAD as code doesn't easily solve is how to refer to parts of the generated model for further processing. Consider adding in fillets to parts of your model. You have generated something complex through a series of sketches and extrusions in different orientations. Now you wish to round off some of the sharp edges in the resulting model but not all of them. Using CAD as code you have the problem of trying to select which edges you want.
Some have tried to generate things like CSS selectors for 3D geometry. It's clever but hard to use. In a GUI CAD system you just click on the edge. In a good GUI CAD system the selections are robust against slight changes in the feature tree.
- benhurmarcel 5y agoI completely agree, and just to point out that the author answered about this below: https://news.ycombinator.com/item?id=30841614 https://news.ycombinator.com/item?id=30841614 In particular this is interesting, although as a mechanical engineer I don't see that as very practical: https://cadquery.readthedocs.io/en/latest/selectors.html https://cadquery.readthedocs.io/en/latest/selectors.html
- regularfry 5y agoSigned distance fields are one approach to this, but it's a very different way of thinking.
- injidup 5y agoHow does a signed distance field robustly allow you to select one edge out of many considering that these edges are an artefact the previous CSG operations you may have performed? These edges may or may not exist, their adjacent faces may or may not exist. They may be an in a non obvious orientation or be near or far from other edges or faces. Any query language or filter would need to be able to robustly handle such a system. OnShape has this but it is not for end users. It is for library developers. End users still get to point and click because it's the most obvious and simple thing to do.
- regularfry 5y agoI mean that part of the problem isn't unique to CAD as code. You've just described the Topological Naming Problem, and handling it is a complete mess. SDFs let you say the reverse: by default fillet everything, and focus on finding ways to parameterise the fillet radius in ways that work for the part.
- injidup 5y agoSorry but no. Well maybe you managed to put a new/old name to the problem but SDFs don't solve selecting an edge or a face or a point out of 5000.
- regularfry 5y agoNothing does. That's what I'm getting at. SDFs give you a different way of thinking about the problem to avoid having to make the selection explicitly which, when you can get away with it, solves for an interesting subset of the problem space, but there is no general solution to the problem you're describing, visual CAD or CAD-as-code. What we do have are mountains of hacks that more or less work to hide that fact. Any CAD package, code or visual, has only two ways to identify topological entities. Either you identify them from their underlying topology ("this edge is the 5th created by the intersection of objects A and B"), or you define some sort of query function over the final shape as it ends up in space, divorced from how it was created ("give me the edge that includes an arc in the XY plane radius r about point B"). Freecad does the former, from what I can see Onshape does something like the latter, but in both cases it's possible to generate a pathological feature tree which breaks under a change you want to make. How easy it is to make that breakage happen (or, conversely, how likely you are to accidentally trip over it in your day-to-day work) is controlled by how high the mountain of hacks is. It's reasonable to say that no current CAD-as-code package solves the problem today but it's not true to say that it couldn't be done. The most obvious approach you could see is where the user clicks to select an element in a rendered preview and some selector string or other gets copied to to the clipboard that they then paste into the code to use directly, just like you can get a usable selector for a DOM element in the same format as you'd write by hand out of Chrome's Dev tools. That would work with either approach, and the fact that you're using a selector string in the same format as you'd write by hand means you can edit it as code when you need to.
- ur-whale 5y ago> The problem CAD as code doesn't easily solve is how to refer to parts of the generated model for further processing. Yes, I very much agree, but that is simply something that needs to be added to 'code as CAD' tools. Software engineering has solved this a long time ago with self introspection. OpenSCAD, to name a specific 'code as CAD' tool sorely lacks a way to "query" an existing assembly and use the result in subsequent modeling. If they added that, it'd be a quantum leap in modeling power for the platform. It's all the more frustrating that the underlying engine (CGAL) fully supports it with the ray-model intersection routine.
- injidup 5y agoTell me. How has software engineering solved a long time ago how to select the single segment shown here? The one marked yellow is selected. https://i.imgur.com/rbGDsvF.png https://i.imgur.com/rbGDsvF.png I just picked this with my mouse within OnShape and it took me one only second to robustly pick it. If you look under the hood as see how OnShape generates robust picking selectors it is not something you really want to try coding by hand. You can do it but it is non trivial. Read https://www.onshape.com/en/resource-center/tech-tips/tech-tip-how-to-use-query-explorer-in-featurescript https://www.onshape.com/en/resource-center/tech-tips/tech-ti... and https://cad.onshape.com/FsDoc/library.html#module-query.fs https://cad.onshape.com/FsDoc/library.html#module-query.fs if you want to learn more how it is done. It is super awesome but not trivial to use. Featurescript is designed to be used in within a GUI environment where you pick something specific and then a new custom feature is added to the feature tree. It is a hybrid code / no-code solution. The end user still performs the typical pick and configure workflow.
- duped 5y agoTypically we'd call this feature "goto definition"
- injidup 5y agoAnd how would you implement "Goto definition?" For a line segment that you didn't directly create and is an incidental artifact of a sequence of CSG operations. The line segment is not "defined" like a variable. There is no line in the code that gives you a declaration. It is a build artifact.