Readit News logoReadit News
fogleman · 2 months ago
It is kinda neat, but OpenSCAD's limitations are the main thing that motivated me to write this Python library to generate 3D meshes used signed distance functions:

https://github.com/fogleman/sdf

One big plus to doing it this way is that it's "just" Python and you can use arbitrary logic to help construct your model.

You can even load an existing 3D mesh and operate on it as an SDF. Great for hollowing, chopping, eroding/dilating, etc. existing models.

I should probably do more with this project. I think there's a lot of interest in this space.

vhanda · 2 months ago
Could you please elaborate on how this is different than the other python based modeling tools - build123d[0] and CadQuery[1].

I recently also got annoyed with OpenSCAD and its limitations and therefore started experimenting with Build123d. I'm very much a beginner in the CAD space and would love to understand what inspired you to build sdf.

My basic understanding is that STL files are essentially like Bitmap images and store a list of triangles and their positions, whereas STEP files are more like Vector art where there is a list of instructions on how to build the model. Most CAD GUI programs also operate on a similar model to vector art where they record a list of operations one on top of another. It's why STEP files are a standardized format and can be imported / exported from most GUI based CAD builders. I think.

Given that SDF also seems like it builds only STL files (I could be wrong), wouldn't learning build123d or CadQuery work better if one cares about compatibility with existing GUI based CAD modeling software?

Additionally, atleast build123d offers a similar conceptual model to using Fusion360 and FreeCad - I have limited experience here - but essentially you sketch something in 2D on a particular plane, and then apply some operations to convert it to 3d in a particular manner - the simplest being extruding. This means the mental modeling of how to construct something is very similar across both GUI based CAD programs and Build123d, and that makes it easier for me to jump between GUI based and code based CAD modelling.

I'd love to understand your point of view, and learn more.

[0] - https://github.com/gumyr/build123d

[1] - https://github.com/CadQuery/cadquery

fogleman · 2 months ago
It seems like you already understand the differences. I wasn't aware of those other projects. build123d looks pretty neat.

Like most of my projects, this was just for fun and I mainly made it for myself. I'm a DIY kind of guy when it comes to software. I just throw things up on GitHub in case anyone else can get some use or inspiration out of it.

ur-whale · 2 months ago
SDFs are very neat up until the point where you need to build parts that have very precise specifications.

Something like two precisely interlocking gears with a tooth geometry with a profile that's the developed curve of the opposite tooth is a nightmare to build with SDFs

Or precise fillets.

Or hard intersections and differences.

Very useful for doing soft, squishy shapes, less so for hard CAD.

Also, a suggestion: in your project, please consider using Wavefront OBJ as an output format, it is a much, much better choice than STL (STL can't represent the actual topology of the object, it has to be reconstructed).

Deleted Comment

jandrese · 2 months ago
> You can even load an existing 3D mesh and operate on it as an SDF. Great for hollowing, chopping, eroding/dilating, etc. existing models.

This has my instant interest. Multiple times I have wanted to take an existing .STL file and cut a hole on it or add another object to it and have never had success.

I've tried things like Meshlab, but while the interface has what appears to be a hundred different functions, attempting to use anything returns some error code that requires a PhD to understand and none of the "repair" functions seem to help.

I mean seriously: Mesh inputs must induce a piecewise constant winding number field.

How the hell am I supposed to accomplish that on a STL file?

Brian_K_White · 2 months ago
You can do that effortlessly right in openscad itself or in freecad for a more visual way, or in every single cad app in existence I think.

In freecad you first just open the stl file, then Part -> Create part from mesh, then you have a solid you can modify.

fainpul · 2 months ago
People should share the original files or at least step files along with the stl files. But if you must work with stl, Fusion works brilliantly for this. You can open the stl file, which gives you the usual mesh that's hard to work with. You then convert that mesh to a solid object, on which you can use "direct modeling". It's not the same as a parametric object, but the editing features are quite powerful and sort of mindblowing. [1]

If you have the paid version of Fusion, you can run "feature detection" to turn things like holes, fillets, extrusions etc. into dedicated features which are even easier to edit. [2]

[1] https://www.autodesk.com/learn/ondemand/curated/direct-model...

[2] https://www.autodesk.com/learn/ondemand/curated/direct-model...

fogleman · 2 months ago
That feature requires getting pyopenvdb installed, which can be a headache, and I never really updated the README with examples, but it does work. There is one example script:

https://github.com/fogleman/sdf/blob/main/examples/mesh.py

You basically just say:

f = Mesh.from_file(path).sdf(voxel_size=0.25, half_width=1)

Then you can operate on `f`.

yaky · 2 months ago
If it's a one-time thing, Prusa Slicer (and some other slicers too, probably) allow adding and subtracting simple shapes. So if, for example, you need to add a hole for a screw, you can do it directly in the slicer without messing with (and breaking the mesh of) an STL.
dekhn · 2 months ago
Blender also has a high learning curve but you typically don't need a PhD to understand the errors (instead you just watch youtube videos and copy what they do).

Removing faces from an STL and adding other objects is quite straightforward. Previously, Autodesk had Meshmixer and 123D, I guess Meshmixer is still available: https://meshmixer.org/ and I found it to be great for quick editing of the type you're describing.

kesor · 2 months ago
OpenSCAD can load STLs and cut holes in them.
btbuildem · 2 months ago
Tinkercad is a very low-barrier-to-entry option here
WillAdams · 2 months ago
Interestingly, PythonSCAD has support for SDF by way of libfive:

https://pythonscad.org/examples.php

(search for "sdf" about halfway down the page)

mosura · 2 months ago
This is brilliant. The ability to do blobby/metaball style blends so easily is a big benefit.
FeepingCreature · 2 months ago
See also my site fncad https://fncad.github.io ! It's basically intended as "SDFs in your browser with realtime preview with openscad-like syntax". I mostly use it for 3d models for printing.

What do you use for sdf meshing? I never really got the perf where I wanted it.

fogleman · 2 months ago
It's explained in the README. The SDF is evaluated on whole batches of points (32x32x32 tiles by default) using numpy. (And it's multithreaded.)

Deleted Comment

userbinator · 2 months ago
From what I know, SDFs were popularised by the demoscene; it's interesting that they've now found more practical applications as a result.
mkl · 2 months ago
They long pre-date the demoscene, going back centuries in mathematics. Ray tracing/casting of implicit surfaces (described with SDFs and more general signed functions) for computer graphics goes back to the 1960s and 70s. The 1990s demoscene 2D metaball effects were based on computer graphics work by Jim Blinn for Cosmos in 1980. Most current applications are based on that long ongoing research. (I did my PhD in implicit surface stuff, so I've seen tons of academic papers on it going back ages, and I never ran into demoscene methods in that context.)
JonathanRaines · 2 months ago
I've used your library and really like it!
zimpenfish · 2 months ago
Bless you for your service, sir! I have used `sdf` to create a whole bunch of stuff (buttons for my mother, tealight holders, etc.) and `gg` gets used in a bunch of places (including a couple of bots).

> I should probably do more with this project.

I, for one, would be glad.

the_cat_kittles · 2 months ago
maybe this will finally be the solution to my tapered variable pitch helix woes. it looks cool, thanks
charlie-83 · 2 months ago
Just started using OpenSCAD recently and love it. While most CAD tools have a million features to learn, OpenSCAD is completely described by a cheat sheet you could print on a piece of A4 (like most programming languages).

I would really recommend using the git master than the latest release though. The last release was 2021 but they are still actively working on it and it's much faster now.

I also have to recommend the BOSL2 library which means you don't have to implement all of those one million features from typical CAD software yourself. Its definitely got a bit of a learning curve but the fact that you can always default back to vanilla OpenSCAD and that you can actually see how stuff is implemented makes it much more satisfying to me to learn than learning what all the traditional CAD GUI buttons do.

porkloin · 2 months ago
Commenting off of you since I wrote all of this and then realized it's basically exactly what you're saying. But to +1 everything you just said in my own words:

I love OpenSCAD. I've been 3D printing for a while, but I never really got to a place where I could design interesting parts until I started to get the precision of doing models in code. Sometimes it is slower, for sure.

Every time I've used as a CAD GUI program I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it. The input devices lack precision for that kind of task, and having to repeat the operation dozens of times (or bulk select) gave me a terrible sinking feeling, and I'd often just step away and give up on the design at that point out of frustration. I try to approach everything in OpensSCAD in a way that means I never have to experience that feeling again.

I will also say that doing everything from scratch in OpenSCAD would be it's own special kind of hell. Libraries like [BOSL2](https://github.com/BelfrySCAD/BOSL2) provide a good set of core ideas and preferences that help set you on a good path. A good example: BOSL2 shapes tend to have a "center origin" by default, which is different than the OpenSCAD default, but makes doing transforms later way easier.

Anyway, happy to see OpenSCAD getting some attention here :)

zargon · 2 months ago
> Every time I've used as a CAD GUI program I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it.

There seems to be some fundamental misunderstanding of CAD here. I can't imagine how you could even design something in CAD in a way that you would end up in this situation.

Arodex · 2 months ago
>Every time I've used as a CAD GUI program I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it.

What.

This makes no sense. This isn't PowerPoint; your holes and cutouts are supposed to be parameterized. How are they even supposed to be at the proper position in the first place?

As a CAD user, this is like e.g. a coder seeing someone write code with global variables everywhere.

0_____0 · 2 months ago
A properly parameterized model shouldn't have the issue with having to nudge everything manually after a trivial change.

I had the change the height of an entire enclosure to accommodate a taller than anticipated PCB, and simply edited the sketch at the top of my design tree that defined the overall dimensions.

It took about 5 minutes to adjust the odd broken fillet and change some mates in assembly and it was done. No fidgety mouse movements. I actually do a lot of mech design on a laptop with a trackpad, arrow keys for view changes and numeric dimensioning for 95% of everything else.

abdullahkhalids · 2 months ago
> Every time I've used as a CAD GUI program I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it.

I am just starting to learn CAD and FreeCAD - also dabbled a bit in OpenSCAD. But I do know that FreeCAD has Spreadsheets [1] and Configuration Tables [2] which allows you to define your model parameterically and changes values as needed.

How good this is, I don't know yet.

[1] https://wiki.freecad.org/Spreadsheet_Workbench [2] https://wiki.freecad.org/Configuration_Tables

RobotToaster · 2 months ago
> Every time I've used as a CAD GUI program I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it.

I can see how you would end up in that position

You need to add constraints to your sketches. In other words tell it that the hole needs to be x distance from certain lines.

If you don't do that what you get is the equivalent of hard coding a hole location in OpenSCAD. I guess OpenSCAD just forces you to think parametrically.

Also in fusion 360 make sure timeline editing is on.

amelius · 2 months ago
I sometimes think that "parametric" is not the right description or the word is used in the wrong way.

As an example, consider a bar with a constrained length, e.g. 1000mm. I want holes in the bar every 100mm (not a strange requirement). Now I change the length constraint to 800mm. Consequently, the number of holes should change. But this seems not possible in a "parametric" modeler. Maybe I'm missing something, though.

Deleted Comment

girvo · 2 months ago
> I would get to this point where I would need to alter a single dimension by 0.25mm and realize that _all_ of my fastener holes, cutouts, etc have to be nudged with the keyboard or mouse to accommodate it

Thats surprising! Last time I used software like this (Inventor, back in ~2005-2006) constraints meant that I didn't need to do this at all

Dead Comment

moebrowne · 2 months ago
> I would really recommend using the git master than the latest release though.

This. The master version is so much further ahead of the last tagged version. The render time can be orders of magnitude faster for more complex models.

jasongill · 2 months ago
It appears that regularly-updated builds are available here: https://openscad.org/downloads.html#snapshots

or with Homebrew you can do `brew install --cask openscad@snapshot` to install the latest snapshot version.

Or, browse all the snapshot builds here: https://files.openscad.org/snapshots/

(as of this comment, the last snapshot build is from yesterday)

exasperaited · 2 months ago
OpenSCAD isn't a CAD tool, IMO. It does nothing at all to aid your design. It barely even helps describe it in any abstract way.

It is a useful tool for programmatically describing either very simple or heavily geometric objects. For everything else it's the wrong tool.

voxleone · 2 months ago
I'd put it this way: CAD = Computer-Aided Design, i.e., software that assists in the creation, modification, analysis, or optimization of a design.

OpenSCAD clearly qualifies because it creates precise 2D/3D models; supports parametric modification; enables reproducible designs; produces manufacturable geometry (STL, DXF, etc.). The fact that it is code-based does not disqualify it. By the same logic, CadQuery, SolidPython, or FeatureScript would also not be CAD - which is not a position held in engineering practice.

cm2187 · 2 months ago
Agree but you quickly run into its limitations. Like if you 3d print something, you need to eliminate when possible sharp edges. That's not fun to do with OpenSCAD.
m4rtink · 2 months ago
BOSL2 is SO nice and powerful, can also highly recommend it! :)
gortok · 2 months ago
Can you link to this cheat sheet?
WillAdams · 2 months ago
Presumably:

https://openscad.org/cheatsheet/

Note that updating it is one of the blockers for a new release, so it doesn't include some newer features/syntax

There is also:

https://cubehero.com/2013/11/19/know-only-10-things-to-be-da...

FWIW, when I need to rough something out in OpenSCAD, I usually use:

https://www.blockscad3d.com/editor/

yoan9224 · 2 months ago
OpenSCAD is perfect for the "programmer's brain" approach to CAD. Being able to parametrize everything means I can design something like a project enclosure once, then generate variants for different screen sizes or component layouts by just changing a few variables.

Pro tip: Use the latest nightly build and switch to the Manifold backend in preferences. Render times drop from minutes to seconds for complex models. The official 2021 release is painfully outdated.

Also, the BOSL2 library is essential - it adds proper filleting, rounding, and attachment operations that vanilla OpenSCAD lacks. Makes the difference between toy projects and actually useful designs.

The Git-friendliness is underrated too. Diffing .scad files is trivial compared to trying to understand what changed in a binary Fusion 360 file.

s0rce · 2 months ago
hmm, I didn't know about the BOSL2, I was struggling with fillets and chamfers, you basically had to figure out how to define them somehow which isn't really straightforward. Been using FreeCAD mostly which still has weird issues with fillets sometimes.
WillAdams · 2 months ago
The great thing about OpenSCAD is that it makes it easy to 3D model things which may be described using spheres, cylinders, and cubes which are stretch, and/or rotated, and arranged in 3D space.

The awful thing about OpenSCAD is that what one can model in 3D is limited by one's ability to mathematically stretch, rotate, and/or arrange spheres, cylinders, and cubes in 3D.

For folks who want "real" (read mutable in normal terms of scope) variables there is a Python-enabled fork (which should become part of the main release presently:

https://pythonscad.org/

IgorPartola · 2 months ago
Not just that but it also positions everything in absolute coordinates and does not have the ability to reason about solids, just surfaces. Basically if you want to model something like a bolt you need to create a cylinder for the shaft, a separate head of the bolt, and then a thread profile you can rotate around the cylinder. You must ensure there is enough overlap between these three separate parts so the resultant object is a single surface and not three separate ones.

You can use modules to create a semblance of relative measurements but you still cannot do things like “attach this surface of object A to that surface of object B)”. In practice this means that if you want to create something like a spacer or a bracket you can do that easily enough. But if you want to make a part that matches some real world design you are stuck doing a lot of caliper measurements and math to try to create a part that lines up correctly. The you 3D print it and find that you positioned some hole based on its edge and not center and so nothing quite fits.

OpenSCAD is easy to start but difficult to scale because of these limitations and because once you hard-code any measurement you are stuck with it. The “proper” way to do this is to give everything a variable but honestly that makes reasoning about how to line things up even more difficult. “Does base_width include the width of the vertical walls? What about the margin to make the parts fit together?”

I have never been able to understand how things like FreeCAD lay out their UI. TinkerCAD is relatively simple but clearly a lot less powerful. I did try cadquery which solved a lot of OpenSCAD’s issues by having all offsets be relative by default but also introduces a few issues of its own.

One tip I will give about OS: grab a copy of the latest beta/dev release. The renderer is several orders of magnitude faster.

c0nsumer · 2 months ago
> You must ensure there is enough overlap between these three separate parts so the resultant object is a single surface and not three separate ones.

(Post author here.)

This was a very weird thing to me I ran into and have thus far just sort of... accepted.

In Fusion, and other CAD software, if I have two faces end at the same point, unless I've specifically said to create them as separate bodies, they are joined, because they share a plane.

In OpenSCAD, in the tutorial, it has you extend an object 0.001 to ensure they overlap. To quote:

> In the example above, the second cube sits exactly on top of the first cube. This is something that should be avoided, as it’s not clear to OpenSCAD whether the two cubes form one object together. This issue can be easily solved by always maintaining a small overlap of about 0.001 - 0.002 between the corresponding objects. One way to do so is by decreasing the amount of translation along the Z axis from 10 unit to 9.999 units.

This struck me when making the example in my post. In line 47 I specifically add 1 to heightCompartment to ensure the opening extends past the top of the main body. If I didn't do that, this happens during preview: https://imgur.com/a/Amc1dK6 (That's an exported image from the latest nightly of OpenSCAD.)

But it doesn't happen during the actual render?

Still, that just feels... like there's something going on with a floating point value or something which, programatically, is probably correct... But from the perspective of someone trying to design something feels Very Wrong. Because I have a 20mm high box, I subtract a 19mm high box from it, starting 1mm up from the base. Why shouldn't the top be open? Why is it acceptable for it to be maybe kinda open but broken by design?

somat · 2 months ago
> but you still cannot do things like “attach this surface of object A to that surface of object B)”

Sure you can, but openscad is an imperative language so you need to do it in an imperative manner.

    a_cube_loc = [10, 5, 5];
    a_cube_size = [2, 4, 1];
    b_cube_loc = [a_cube_loc[0], a_cube_loc[1] + a_cube_size[1], a_cube_loc[2] ];
    b_cube_size = [2, 4, 1];

   translate(a_cube_loc) cube(a_cube_size);
   translate(b_cube_loc) cube(b_cube_size);
It would be nice to have more declarative constraints. The solvespace file format is plain text and it almost feels like you could write it by hand, but that would be a lot of manual record keeping. and you would loose all that imperative goodness. Perhaps you could have an imperative layer(say python or lisp or forth) that outputs the declarative layer(solvespace) and then solvespace renders(picture or stl) the declarative layer.

coryrc · 2 months ago
BOSL2 allows attaching when you define attachment points or something with attachment points defined for you (most everything in BOSL2).

Manifold backend also eliminates the need to avoid coincident faces.

m4rtink · 2 months ago
Let me introduce to the awesomness of the BOSL2 screw module:

https://github.com/BelfrySCAD/BOSL2/wiki/screws.scad

ur-whale · 2 months ago
> I have never been able to understand how things like FreeCAD lay out their UI.

I'm 100% with you there. One of the most utterly confusing UI I've had to deal with.

And I suspect the answer is : the FreeCAD devs don't either.

RobotToaster · 2 months ago
> The great thing about OpenSCAD is that it makes it easy to 3D model things which may be described using spheres, cylinders, and cubes which are stretch, and/or rotated, and arranged in 3D space.

It also has hulls and minkowski sums, which are powerful once you understand them.

WillAdams · 2 months ago
Aren't hulls just a direct connection of the edges of two shapes (which could be simulated by a series of duplications) while Minkowski is "just" a matter of putting spheres along the edges of an object to round the straight edges?

So, spheres and cylinders and cubes placed, rotated, stretched and placed mathematically.

culi · 2 months ago
There's also OpenJSCAD. Which, being JavaScript ofc, can run in the browser

https://openjscad.xyz/

https://github.com/jscad/OpenJSCAD.org

xixixao · 2 months ago
From my testing, the CSG operations, with post-processing, don’t produce watertight meshes. And being focused on printing, it doesn’t support different colors for the CSG operands. My use case is animation/games, so I’m reimplementing the CSG with a watertight b-rep.
rafabulsing · 2 months ago
Re: JS based CAD, there's also replicad, which I've used previously and found to be really good.

https://replicad.xyz/

spwa4 · 2 months ago
Don't people think this is one tool that would greatly benefit from using the very fastest languages available? Where's the C++, Rust, maybe even FORTRAN version?
jandrese · 2 months ago
You can also make more complex shapes if you're willing to define points, even on a 2D plane that you can then extrude. Downside is that it's basically a MENSA test to define all of the points in the correct order. I've done it a few times, but it's never fun.
anthk · 2 months ago
Solid of revolutions and Bezier curves. That and some elementary Calculus will help everyone a lot.
coryrc · 2 months ago
Also you can use the new backend by writing C++: https://github.com/elalish/manifold

Which avoids using the OpenSCAD language, but also means you can't use BOSL2. Might as well use FreeCAD.

pca006132 · 2 months ago
It has many language bindings, including python and js. Though the js backend is not parallel because it uses wasm, and we had problem with mimalloc memory usage with pthread enabled.
tombert · 2 months ago
I think people should also give Bowler Studio a shot. It has a pretty decent Java-based CAD thing, and it even has built in Clojure support, with physics simulation support and everything. I really like it.
JoshTriplett · 2 months ago
Another interesting option is FreeCAD, which is scriptable in Python but its primary interface is a GUI. So you can use a script to create things programmatically, edit graphically, or both.
criddell · 2 months ago
FreeCAD sounds great but in practice it’s sooo slow.

If you are coming from SolidWorks, Fusion360, Inventor, or OnShape, it won’t take long before you start finding that there are a lot of things missing from it.

WillAdams · 2 months ago
Isn't the Python scripting in FreeCAD just a direct representation of the internal object model?

It's _not_ something which was designed for ease of use, or rational semantics, or to facilitate expression.

ai-christianson · 2 months ago
I've had really good luck with https://github.com/SolidCode/SolidPython
NortySpock · 2 months ago
I ended up adding the https://github.com/BelfrySCAD/BOSL2 library to OpenSCAD and it had some reasonable options for some gear and rack-and-pinion modeling that I needed to do.

(3D printing a sacrificial gear for a seat position adjustment mechanism)

ur-whale · 2 months ago
> https://pythonscad.org/

Thanks for this, didn't know about it.

How does that compare to solid python 2?

https://github.com/jeff-dh/SolidPython

WillAdams · 2 months ago
It's native and more direct.

Rather then adding an additional compile cycle:

- run Python code to generate OpenSCAD code

- render OpenSCAD code to see output

OpenPythonSCAD creates a .py code window in the OpenSCAD interface which one interacts with in the same way as a .scad code window (there's even basic support for the Customizer).

I suspect it would be really easy to port SolidPython to work w/in OpenPythonSCAD (if it hasn't already been done)

TOGoS · 2 months ago
> The awful thing about OpenSCAD is that what one can model in 3D is limited by one's ability to mathematically stretch, rotate, and/or arrange spheres, cylinders, and cubes in 3D.

Not at all. You can build any polyhedron you want using the polyhedron command.

Which would be an enormous pain to write out by hand every time, but I wrote a function once upon a time to generate a polyhedron from a stack of layers, each of which is a list of points, and haven't had to mess with old cubes and spheres since.

One annoying thing is that the default way of writing programs in OpenSCAD uses 'modules', which are a bit limited compared to functions (you can't store them as values to to functions or other modules). I worked around that by writing a module that interprets arrays (think S-expressions) that representing the shape, and then just build up that S-expression-like thing with functions and whatever.

Once you've built your own programming language inside OpenSCAD it's perfectly usable. :-)

This might sound like sarcasm but I actually do prefer this to dealing with Python's mutable state jungle / package management nightmare.

WillAdams · 2 months ago
Fair point.

This sounds _fascinating_ have you posted your code or written this up in a math journal? Link?

I don't touch polyhedrons in OpenSCAD because the logic of point placement mystifies me --- a tool such as you describe would make life a lot easier for a lot of folks, esp. if there was a way to use it to import a series of SVG files which could be used to define the points interactively.

I sometimes wonder if the key to future computer usage would be a series of Domain Specific Languages each intended for a given task:

- 3D == OpenSCAD

- 2D == METAPOST

- SQL == databases

- TeX == text/page composition

- sed == text

(and yes, I know this is the Unix ideal)

but such languages seem to be most successful and most approachable to typical users when they are paired with a front-end which affords editing, previewing, and, direct interaction.

I'm actually nuking my Python install right now, because I got it into a state where I couldn't get Fullcontrol G-code to run, so I agree that the state of Python package population is pitiful, hence of course, the XKCD:

https://xkcd.com/1987/

M_bara · 2 months ago
Or perhaps take a look at cadquery? It’s also pretty neat - http://cadquery.readthedocs.io/
elcapitan · 2 months ago
For me as a casual 3d-modeler, my favorite thing about OpenSCAD is that I don't have to learn a new application the size of Photoshop with everything hidden 7 levels deep in some menu that is probably intuitive for some people who learned CAD in the 80s.

Instead it's basically like graphics programming, with a couple of basic primitives, some linear transformations and a bit of set theory. When I do a model a month and get back to previous work, I read a few lines of code and know exactly how I achieved the result.

unbelievably · 2 months ago
I was once a big OpenSCAD user myself but I'm really skeptical that there are many use cases where it's actually more intuitive than a traditional CAD program, even if you're a programmer. It's true CAD programs have a huge amount of features but the basic sketch, extrude, revolve, and loft tools aren't conceptually difficult and are basically the same between Onshape, Fusion, Solidworks, etc. Those tools are sufficient to make 99.99% of OpenSCAD models I'm seeing.

I also have the opposite experience about understanding previous scripts. Unless it's dead simple I'm usually thinking why the hell did I multiply this thingy by sqrt(3)/2 plus this other thing. Maybe a documentation problem, but it's inescapable that sometimes you need a lot of math for what are trivial constraints in an interactive sketch. A real CAD program will let you roll back to any feature to figure out how it's constructed step by step so there's really nothing to decipher.

IshKebab · 2 months ago
Yeah I agree. OpenSCAD is good for highly parametric modelling: fasteners, gears, generative art, ... that's about it. Most things aren't like that, and a traditional parametric CAD program is 10x easier.
WillAdams · 2 months ago
I've been trying to model joints for woodworking, and in traditional tools, the shapes I wish to arrive at verge on nightmarish, while I was able to knock them out in OpenSCAD in pretty short order --- except that when I sent a 1" x 2" x 1" test joint to a CAM program, it took some 18 minutes and generated a ~140MB G-code file, hence my working on:

https://github.com/WillAdams/gcodepreview

wat10000 · 2 months ago
The older I get, the less I want GUIs. If I want to rotate something, I want to type “rotate,” not find the rotation icon or menu item or remember the keyboard shortcut or whatever.

I know this is not typical, and nothing against folks who see it the other way. But OpenSCAD fits the way I think and want to work better than the more “normal” tools.

convolvatron · 2 months ago
I love the model, it's nice to be able to generate things parametrically instead of grabbing knots with the mouse. so I use scad pretty often.

but it has real problems - the language is weird and unfortunate. not anything super fatal, just the obvious product of evolution that would be more cohesive if it were architected wholesale

  epsilons are really unfortunate. you have to expect that after getting what you want in the whole, you're going to have to scan over the whole thing and look for cracks or collision where there shouldn't be 

  performance is quite sad. here you are happy going back and forth between the view and text windows, but as you go on, it starts taking .. minutes.. to update the view once you have a reasonably complicated geometry

  high-level operators would also be nice. I made the mistake of using a thread library once, not only did that make my model unrenderable, there was so much noise in the model and the manufacturing process I had to make 3 expensive test prints in sintered nylon to get the fit right. (I'm thinking an annotation on a cylinder that says 'standard 1mm thread')

MattRix · 2 months ago
It actually renders things incredibly fast if you get the nightly version and set the backend to Manifold. It is probably 100x faster (!!). In fact it renders so fast that I put a render() command at the top of my hierarchy so that everything just renders all the time, it’s faster and more performant. I make incredibly complex models with it too, with hundreds of holes, complex svg files with text in them, etc.
coryrc · 2 months ago
Why not just press F6 instead?
WillAdams · 2 months ago
If you're inclined to use Python there is:

https://pythonscad.org/

Brian_K_White · 2 months ago
It's a lot of work to make models that are useful in real life, but for some things it's worth it because it's sooo nice having 2k of plain text that describes an entire object, and it's even fully parametric, and it even comes with a customizer panel for the parameters, so every model isn't just a model, it's a model generator app, and even has meaningful diffs in git.

The same model in freecad is like 6 megs of zipped xml and realistically not nearly as usefully parametric.

That couple-k of plain text is such a huge deal that it makes all the other difficulty worth it for mechanical/functional stuff.

dheera · 2 months ago
OpenSCAD is the only CAD tool I use. I can'd figure out how to operate a graphical 3D software with a 2D GUI so it's just easier to describe things mathematically.

I just wish it had operations for subtractively chamfering, rounding, etc. as doing minkowski() with cones and spheres to achieve that result can be unwieldy.

Brian_K_White · 2 months ago
A few years ago I made a little module rounded_cube that generates a cube by drawing 1/8 spheres wrapped in hull, andnsince then I've been using that for everything, making inside fillets by using a rounded cube as a cut shape. Since it can generate a hollow box with a desired wall thickness, you have the shell of an enclosure box in a single call.

Over time I added other things like a single linear fillet, a single radial fillet, both interior and exterior, convenience things built out of those like a screw post with a fillet base etc. But really I always end up just using mirror_copy and rounded_cube a lot.

There is a scifi book series aboit a programmer who gets zapped into a fantasy world that has magic, and he becomes the most powerful wizard in the world because he applies the coding concept of reusable components and building big things out of smaller things and automation, which none of the other wizards ever thought of.

openscad is like that. To get anywhere you first have to build a library of useful higher level things out of the low level things. Like forth or assembly, or really all programming I guess.

derkades · 2 months ago
Do you know about BOSL2? It can do rounding or chamfering very easily.

cuboid([20, 20, 30], chamfer=5);

bb88 · 2 months ago
I find that I'm often making one-offs. I take a part I designed and I need a slight modification for it for some reason.

Fusion is great for that as long as there's not too many parts. But sometimes I'll want a new variant or a series of new variants.

And reaching for python makes that easy.

anfractuosity · 2 months ago
It's super useful, been using with my 3D printer to print things such as an adapter to connect a Canon EF lens to night vision tube and parts to link motorised linear stages together.

Currently I'm playing with a gear library which is part of BOSL2 (https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad), to make something to rotate a polariser in my microscope.