OpenSCAD

Are there any experienced OpenSCAD scripters here?

I am running into a problem with “minkowski” when I try to round edges. The PC either hangs or needs more than half an hour to render. I do not have the patience to wait that long. Does anyone know of a way to remove sharp edges quicker than minkowski?

I tried a simple cube with rounded edges and that worked fine. Probably my shape is too complex.

module donut_with_lobes() {
outer_diameter = 70;
inner_diameter = 30;
protrusion = 15;
lob_count = 5;
round_radius = 1;
hex_diameter = 13;
hex_depth = 5;
torus_diameter = (outer_diameter - inner_diameter) / 2;
R = (outer_diameter - torus_diameter) / 2;
hex_correction = hex_diameter / cos(30) + 0.2; // 0.2 mm tolerance

union() {
    difference() {
        union() {
            rotate_extrude(angle = 360)
                translate([R, 0, 0])
                    circle(r = torus_diameter / 2, $fn = 100);
            translate([0, 0, -torus_diameter / 2])
                cylinder(h = torus_diameter / 2, r = outer_diameter / 2 - torus_diameter / 2, $fn = 100);
            translate([0, 0, -torus_diameter / 2])
                cylinder(h = torus_diameter / 2, r = inner_diameter / 2, $fn = 100);
            translate([0, 0, -torus_diameter/2-protrusion])
                cylinder(h = torus_diameter/2+protrusion, r = inner_diameter / 2, $fn = 100);
        }
        translate([0, 0, -torus_diameter/2-protrusion - 0.1])
            cylinder(h = hex_depth, d = hex_correction, $fn = 6);
        translate([0, 0, -torus_diameter/2-protrusion - 0.1])
            cylinder(h = torus_diameter/2+protrusion+0.2, d = 8.5, $fn = 24);
        
        for (i = [0 : lob_count-1]) {
            rotate([0, 0, i * 360 / lob_count])
                translate([R + torus_diameter / 2, 0, -torus_diameter])
                    cylinder(h = torus_diameter * 2, r = torus_diameter / 2, $fn = 50);
        }
    }
}

}

donut_with_lobes();

There is or was a setting in preferences which fixed rendering speed issues like you are describing but I don’t recall exactly what it is.

1 Like

Download the current development version, which now uses the new Manifold kernel, which is tremendously faster. At least, I believe it’s now enabled by default; I enabled it before it was turned on by default, basically immediately after it was integrated into OpenSCAD.

That changed “minkowski means go to lunch while it renders” to “blink and you miss it” for most models I’ve seen. With your model, rendering (not preview!) gives me:

Total rendering time: 0:00:00.034

Even adding $fn=180 to the top of your script to make it smoother doesn’t make it slow:

Total rendering time: 0:00:00.022

Why it’s even faster when it’s finer I don’t know. Maybe it’s measurement noise.

They don’t do frequent releases; the Manifold kernel has been used in development versions of OpenSCAD for about two and a half years. Looking forward to a new official stable release someday! :smiling_face:

3 Likes

Yup, crazy fast now.

1 Like

The script above froze my system completely, with $fn=180 (and minkowski) I could not move the mouse pointer anymore. I had to reboot.

I simplified the script to this (and installed the latest version):

// v.2021-01 $fn=12 lob_count = 1 Total rendering time: > 7 minutes
// v.2025-11 $fn=12 lob_count = 1 Total rendering time: 0:00:07.342
// v.2025-11 $fn=32 lob_count = 1 Total rendering time: 0:00:23.187
// v.2025-11 $fn=64 lob_count = 1 Total rendering time: 0:01:20.007
// v.2025-11 $fn=64 lob_count = 2 Total rendering time: 0:01:20.007
// v.2025-11 $fn=64 lob_count = 2 Total rendering time: 0:01:43.993
// v.2025-11 $fn=64 lob_count = 6 Total rendering time: 0:02:10.010 minkowski $fn - 12
// v.2025-11 $fn=64 lob_count = 6 Total rendering time: 0:02:28.766 minkowski $fn = 32

module rounded_donut_with_lobes(lob_count = 6, round_radius = 1) {
fn = 12;
outer_diameter = 90;
inner_diameter = 30;
torus_diameter = (outer_diameter - inner_diameter) / 2;
R = (outer_diameter - torus_diameter) / 2;

module base_shape() {
    difference() {
        rotate_extrude(angle = 360)
            translate([R, 0, 0])
                circle(r = torus_diameter / 2, $fn = fn);

        for (i = [0 : lob_count-1]) {
            rotate([0, 0, i * 360 / lob_count])
                translate([R + torus_diameter / 2, 0, -torus_diameter])
                    cylinder(h = torus_diameter * 2, r = torus_diameter / 2, $fn = fn);
        }
    }
}

minkowski() {
    base_shape();
    sphere(r = round_radius, $fn = fn/2); 
}

}

rounded_donut_with_lobes(lob_count = 1, round_radius = 5);

When the details get better the execution time doesn’t. In the top of the script you can see how much slower rendering gets when I add more detail.
It is impossible to develop a shape when minkowsky takes minutes to render everytime I make a small change to the script. For the moment I made a parameter for $fn and during delevopment I leave that to 12. When I’m finished I will change that to 64 and create the .stl to get this level of detail:

Going back the the initial question, could there be a faster solution then minkowski?

@hennep There is a lot of OpenSCAD experience here in this forum, so we can probably help :wink:

Your original model runs perfectly on my (12core 32Gb) laptop, even if I turn $fn up to 360 it still runs with no precipitable lag in the preview. Final rendering takes 1 minute, 4 seconds, and that rendered view is only very slightly laggy when I move it with the mouse.

  • This is OpenSCAD version 2025.12.01 (git dc495e2f1) on Fedora Linux, I build OpenSCAD myself on this machine because the default versions from the Fedora and Debian distributions are years out of date.

What version of OpenSCAD do you use? Helpabout in the menus..

From your description I assume this is affecting the ‘preview’ view? as well as the final rendering.?

If the problem is with the preview itself:

Can we have more details about the system you are running it on? a laptop? desktop? Pi?, how much memory and what sort of CPU (and what sort of graphics system?).

If the problem is only with the final rendering then check you have Manifold set as your rendering engine:

As @dougl and @mcdanlj have said; Please make sure you have a really recent version; and make sure that you have 'Manifold selected as the rendering engine in EditPreferences

Manifold is several orders of magnitude faster than the older CGAL!


1 Like

@hennep to be clear you will not have to build it yourself; you can download new builds. Just download the latest development snapshot for your OS.

This is why I said:

and not “Download the current release”, and why I followed up with

The point I wanted to make is that depending on where you obtain OpenSCAD you may, or may not, get a recent version with manifold. The definitive test is to look at the setting in preferences.

Henny; Where do you see the problem? is it only happening when you press the ‘Render’ button (fn-6), or does it happen in the ‘Preview’ view (fn-5) as well?

I’m currently working on a model that final renders in milliseconds.. but the preview is lagging at one frame every few seconds. So I wonder if this is a related issue..

@easytarget, the original model probably runs fast at every PC. I left minkowski out of it.
These are the specifications of my PC:

inxi -Fxz
System: Kernel: 5.4.0-216-generic x86_64 bits: 64 compiler: gcc v: 9.4.0 Desktop: LXQt 0.14.1
Distro: Ubuntu 20.04.6 LTS (Focal Fossa)
Machine: Type: Laptop System: Notebook product: NHxxRZQ v: N/A serial:
Mobo: Notebook model: NHxxRZQ serial: UEFI: INSYDE v: 1.07.01 date: 06/25/2019
Battery: ID-1: BAT0 charge: 45.8 Wh condition: 45.8/48.0 Wh (95%) model: Notebook BAT status: Full
CPU: Topology: 6-Core model: Intel Core i7-9750H bits: 64 type: MCP arch: Kaby Lake rev: A L2 cache: 12.0 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 31199
Speed: 900 MHz min/max: 800/4500 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 4: 902 5: 900 6: 900
Graphics: Device-1: Intel UHD Graphics 630 vendor: CLEVO/KAPOK driver: i915 v: kernel bus ID: 00:02.0
Display: x11 server: X.Org 1.20.13 driver: modesetting unloaded: fbdev,vesa
resolution: 1920x1080~60Hz, 2560x1440~60Hz
OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2)
v: 4.6 Mesa 22.2.0-devel (git-d2ab0ed 2022-05-09 focal-oibaf-ppa) direct render: Yes
Audio: Device-1: Intel Cannon Lake PCH cAVS vendor: CLEVO/KAPOK driver: snd_hda_intel v: kernel bus ID: 00:1f.3
Sound Server: ALSA v: k5.4.0-216-generic
Network: Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel port: 4040 bus ID: 02:00.0
IF: wlp2s0 state: up mac:
Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: CLEVO/KAPOK driver: r8169
v: kernel port: 3000 bus ID: 03:00.1
IF: enp3s0f1 state: down mac:
Drives: Local Storage: total: 1.38 TiB used: 825.42 GiB (58.6%)
ID-1: /dev/nvme0n1 vendor: Intel model: SSDPEKNW512G8 size: 476.94 GiB
ID-2: /dev/sda vendor: Crucial model: CT1000MX500SSD1 size: 931.51 GiB temp: 39 C
Partition: ID-1: / size: 468.09 GiB used: 242.69 GiB (51.8%) fs: ext4 dev: /dev/nvme0n1p2
ID-2: /home size: 916.70 GiB used: 582.71 GiB (63.6%) fs: ext4 dev: /dev/sda1
Sensors: System Temperatures: cpu: 62.0 C mobo: N/A
Fan Speeds (RPM): N/A
Info: Processes: 274 Uptime: 4h 27m Memory: 15.34 GiB used: 8.40 GiB (54.7%) Init: systemd runlevel: 5
Compilers: gcc: 9.4.0 Shell: bash v: 5.0.17 inxi: 3.0.38

With full minkowski rounding it is slow when I click the preview button and when i load the script from file. If you want to test it yourself, below is the latest version. You can compare the running time with the values at the top of the file. I haven’t tried to render yet.
At this moment I am struggling with a 8.5mm hole and space for the 13mm hex nut. I don’t want those rounded for obvious reasons and I cannot add those after the minkowsky function.

fn = 24; // Total rendering time: 0:00:17.134
//fn = 48; // Total rendering time: 0:00:53.075
//fn = 96; // Total rendering time: 0:05:22.145
outer_diameter = 70;
inner_diameter = 30;
lob_diameter = 44;
protrusion = 10; // from top
lob_count = 5;
round_radius = 4;
hex_diameter = 13; // in mm between flat sides
nut_depth = 5; // in mm

torus_diameter = (outer_diameter - inner_diameter) / 2;
hex_correction = hex_diameter / cos(30) + 0.2; // 0.2 mm tolerance

module donut_with_lobes() {
R = (outer_diameter - torus_diameter) / 2;
union() {
difference() {
union() {
rotate_extrude(angle = 360) // donut
translate([R, 0, 0])
circle(r = torus_diameter/2, $fn = fn);

            translate([0, 0, -torus_diameter/2]) // flat side
                cylinder(h = torus_diameter/2 + torus_diameter/3, r = outer_diameter / 2 - torus_diameter / 2, $fn = fn);
                               
            translate([0, 0, -torus_diameter/2]) // protrusion
                cylinder(h = torus_diameter + protrusion, r = inner_diameter / 2, $fn = fn);
        }
        
        for (i = [0 : lob_count-1]) {
            rotate([0, 0, i * 360 / lob_count])
                translate([R + lob_diameter/2, 0, -torus_diameter])
                    cylinder(h = torus_diameter*2, r = lob_diameter / 2, $fn = fn);
        }

                   
    }  
}

}

minkowski() {
donut_with_lobes();
sphere( r = round_radius, $fn = fn/2 );
}
difference() {
translate([0, 0, -torus_diameter/2 - 0.1]) // M8 hole
#cylinder(h = torus_diameter + protrusion + 0.2, d = 8.5, $fn = fn);

translate([0, 0, torus_diameter/2 + protrusion - nut_depth- nut_depth]) // M8 nut
    #cylinder(h = nut_depth + 0.2 , d = hex_correction, $fn = 6); 

}

With $fn=96 the result is this:


Much nicer than I can 3d-print

@mcdanlj, I ran “sudo snap install openscad-nightly”

In this version, 3d-rendering was set to “Manifold” by default.

1 Like

Thankyou @hennep , your system specs look good, which version of openscad does the help-about box report?

Thank you Owen,
For taking the time to analyse the problem :smile:

version 2025.11.01

1 Like

The latest version of your model take much longer on my machine now that minkowski is enabled.

Not a solution, just a comment, I switched to FreeCAD because of how difficult it is to add fillets and chamfers to selected parts of the model.

System:

  Kernel: 6.8.0-87-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0
  Desktop: KDE Plasma v: 5.27.12 Distro: Kubuntu 24.04.3 LTS (Noble Numbat)
    base: Ubuntu
Machine:
  Type: Laptop System: LENOVO product: 80FG v: Lenovo Z70-80
    serial: <superuser required>
  Mobo: LENOVO model: Lenovo Z70-80 v: 31900058 WIN
    serial: <superuser required> UEFI: LENOVO v: ABCN80WW date: 05/18/2015
Battery:
  ID-1: BAT0 charge: 27.6 Wh (100.0%) condition: 27.6/37.6 Wh (73.5%)
    volts: 15.8 min: 14.4 model: Lenovo IdeaPad status: full
CPU:
  Info: dual core model: Intel Core i7-5500U bits: 64 type: MT MCP
    arch: Broadwell rev: 4 cache: L1: 128 KiB L2: 512 KiB L3: 4 MiB
  Speed (MHz): avg: 2895 high: 2897 min/max: 500/3000 cores: 1: 2896 2: 2894
    3: 2897 4: 2894 bogomips: 19156
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: Intel HD Graphics 5500 vendor: Lenovo driver: i915 v: kernel
    arch: Gen-8 bus-ID: 00:02.0
  Device-2: NVIDIA GM108M [GeForce 840M] vendor: Lenovo driver: nvidia
    v: 580.95.05 arch: Maxwell bus-ID: 04:00.0
  Device-3: Syntek Lenovo EasyCamera driver: uvcvideo type: USB
    bus-ID: 1-6:5
  Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.6 driver: X:
    loaded: modesetting,nvidia unloaded: fbdev,nouveau,vesa dri: iris gpu: i915
    resolution: 1920x1080~60Hz
  API: EGL v: 1.5 drivers: iris,nouveau,nvidia,swrast platforms:
    active: gbm,x11,surfaceless,device inactive: wayland
  API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: intel mesa
    v: 25.0.7-0ubuntu0.24.04.2 glx-v: 1.4 direct-render: yes renderer: Mesa
    Intel HD Graphics 5500 (BDW GT2)
  API: Vulkan v: 1.3.275 drivers: N/A surfaces: xcb,xlib devices: 3
....
Swap:
  ID-1: swap-1 type: file size: 512 MiB used: 368.7 MiB (72.0%)
    file: /swapfile
  ID-2: swap-2 type: file size: 2.34 GiB used: 1.02 GiB (43.6%)
    file: /var/lib/swapspace/1
Sensors:
  System Temperatures: cpu: 61.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Memory: total: 16 GiB available: 15.53 GiB used: 7.73 GiB (49.7%)
  Processes: 310 Uptime: 19d 14h 26m Init: systemd target: graphical (5)
  Packages: 3073 Compilers: gcc: 13.3.0 Shell: Bash v: 5.2.21 inxi: 3.3.34
1 Like

No worries Henny; when I’ve cycled home from my ‘dagje uit Amsterdam’ I’ll try your latest version and see how it behaves on my system.

I’m going to add the obligatory ‘upgrade Ubuntu’ note here, 20.04 is a really old version and improvements in the X/desktop/gpu system since then might speed things up (everywhere). However; I’m not suggesting that as a solution here.. I’m not one of those fools who thinks upgrading an OS is easy; especially Debian based ones like Ubuntu where you really need to full-backup, reinstall and recover+reconfigure. Not an easy or fast thing to do.

1 Like

I’ve used Autocad many years ago and I use SketchUp regularly. Autocad was difficult to start with and after that I started with SketchUp and I was surprised how easy it was to start drawing immediately. Then I tried FreeCAD and I couldn’t even start drawing. I have been staring at it for nearly an hour and could not draw a single line.

It is important to me that a program is intuitive and FreeCAD is definitely not. When it is necessary to do a course to start using a program, I toss it aside.

But there is still hope, you mentioned fillets and chamfers. I will look into that.

FWIW, I had tried FreeCAD 3 different times before 2020 or 2021 and always went back to OpenSCAD. Then a guy offered to do a weekly video chat to teach Fusion360 and because I was able at that moment in time install it on Linux I went through 8 weeks with the group. Hit some snags in F360 and was told oh ya, that bug’s been there for years, do it this way to get around it. Then a file incompatibility came up which required an update to my 2 month old install and F360 no longer worked on Linux and that was right when Autodesk was changing the rules for free accounts which included removing STL export so I asked about FreeCAD and people told me it’s much easier to use now but use the beta which is about to go mainstream. v0.92 IIRC so I did and was amazed at how my basic F360 skills translated and now I understood how to use the sketcher and the other tools.

Could I have done it without any basic CAD experience? Doubtful but it has become a much more user friendly too but not a SketchUp or TinkerCAD like tool. @mcdanlj will probably see a better/more efficient way to make your design but I would first try:
1)sketch half of the oval on the ZX plane which is your main body and rotate the sketch to make the squished 3D oval.
2) create a subtractive cylinder with the radius large enough to be one of the cut-outs and then replicate/rotate to create the 5 cut-outs. I forget the matix operation which lets you revolve and replicate but a google search an a short video by people like MangoJelly or JokoEngineering will show how that’s done.
After adding the one subtractive cylinder to to Part Design->Apply a Pattern->PolarPattern and then change from 2 to 5 the pattern number
3) do an additive cylinder down the center.
4) add other features
5) selected edges then apply a bevel
6) save
7) go to Mesh workbench, create a mesh, right-click the mesh in the tree and select export STL
note, I don’t save the additional mesh stuff so if/when I go modify it’s not extra steps deleting those or hiding those features.

I did not make this a parametric design like I usually do as it was just an exercise. Otherwise Iwould have created a Spreadsheet and set up variables for many of the things you’d setup in OpenSCAD.


PolarWidgetUnnamed.FCStd (237.9 KB)

2 Likes

SketchUp is surface modeling, and doesn’t tend to create manifold objects. Reasonably easy to use for its intended purpose, but not intended for this kind of design. It was used a lot in the early days of openbuilds and as a result there are a lot of “approximate” objects out there that basically need to be re-drawn to be used for CAM or indeed anything other than mocking up. While I haven’t used it recently, SketchUp certainly was wonderful for quick mockups and getting quickly to rendering, and I have used it for that purpose. I am not familiar with its recent capabilities.

If OpenSCAD was so intuitive that you were able to use it without learning anything, my hat’s off to you. I say this as someone who found OpenSCAD initially more accessible than FreeCAD given the OpenSCAD cheat sheet. But I would have been lost in OpenSCAD without the cheat sheet, and now I’d say both that FreeCAD has become far easier to use than it was then, and that MangoJelly’s tutorials have made it reasonably easy to understand the FreeCAD operating model. But I wouldn’t expect to just open it up and start modeling. I also wouldn’t expect that in commercial solid modelling CAD. Not F360, not SolidWorks, not CATIA…

I’m not sure what solid modelling CAD program, GUI or textual, is both intuitive and powerful. Perhaps CaDoodle - Free Offline CAD Alternative to Tinkercad would fit the bill for you? I haven’t tried it, but its target audience is non-specialist. I haven’t looked at all, not even to learn whether it offers dress-up operations like fillets and chamfers.

FreeCAD Part Design workbench added “direct manipulation” this past summer as part of the Google Summer of Code, and the upcoming 1.1 stable release (currently a release candidate with just a few blocking issues between it and release) allows you to grab objects and manipulate them directly with mouse actions, instead of typing in numbers for dimensions. I’ve almost never used it, because I have gotten so used to typing numbers that it now feels easier to me than dragging things around with a mouse. But you might find that a helpful affordance.

Oh no, I’ve been nerd-sniped!

I don’t know if it’s “better” but I’ll try to make an exact replica, relatively parsimoniously.

Sketch on YZ plane:

Revolve:

Sketch on XY plane, import the torus as construction geometry, select section view, then make a circle constrained to the Y axis (X would work too) with the center constrained to the outside of the torus, and the diameter constrained tangent to the center:

Pocket:

You can just drag it through the toroid using direct modeling, but I’d just change to “Through all”, and reverse it so that it goes up from the base plane:

At this point, I discovered and reported a bug. I expect the bug is in the OpenCASCADE library that FreeCAD uses for its geometry kernel, rather than in FreeCAD proper. I had to offset the circle slightly from the center of the torus for it to cut correctly. Moving on with that workaround!

Now a Polar pattern with five instances:

Another sketch on the XY plane with the hexagon constrained the way you did in the OpenSCAD. (Note that if I were doing this from scratch I’d be constraining it by distance across flats as measured with calipers or by specification, not by the diameter around the points.)

Now pocket that 5mm in (again reversed because I’m building up in Z):

At this point we have the same thing you uploaded originally: Knob.FCStd (871.6 KB)

Now you want some fillets for comfort, right? Hover over the face of the torus (here, light green) and click to select (here, light blue):

Then select the fillet operation:

You can either drag the arrows to change the size, or modify the radius by clicking the up/down arrows or entering a size. Here it is with a 6mm radius:

Now I click OK and get the model

It renders quickly in FreeCAD and can be exported in whatever form you like, including STEP and STL. Here’s this final version: Knob.FCStd (871.6 KB)

3 Likes

What I really love about FreeCAD, possibly other CADs, are the options for how to make things. I whipped up a one-off using default objects(cylinders) once the squished oval was made in the sketch. But you can see from Michael’s very thorough walk-thru, you can design the central platform and hole all in the sketch. And we can set constraints which are easily associated with Spreadsheet variables so just by tweaking numbers in the spreadsheet with the final design updating.

People just need a desire to hammer on these basic things a little to feel comfortable remembering the steps/process. And there’s so much more available should they find a need to so things which are more complex.

1 Like

FreeCAD 1.0 introduced a new feature, the VarSet, which has typed variables that you can get to without going into a spreadsheet. It is more robust, and I think usually easier, than using a Spreadsheet — though the Spreadsheet is still available. I can’t remember if I’ve ever use a Spreadsheet since I started using VarSets. You can see how extensively I’ve used them if you look at my design for a Morse Code key. It’s easier to document because I don’t have to point people to a spreadsheet and then suggest that they not accidentally change something they didn’t mean to. And when I’ve needed some complex expressions, the fact that VarSets do dimensional analysis to enforce their types (e.g. a length times a length gives you an area) has caught a couple of subtle bugs right away, so that I didn’t end up looking at a model and wondering why it was weird.

Anyway, strong recommendation for VarSets as the parameterization tool of choice now.

1 Like

Thanks, I will look into that. While I like parameterization ever since starting in OpenSCAD, coders will do that, I was not thrilled with the Spreadsheet format for it so it won’t be difficult to move me off of Spreadsheets.

1 Like

The above discussions remind me that I really need to give FreeCAD another try. Parametrisation is one of the key things I like about OpenSCAD, and FreeCAD’s ‘spreadsheet’ was a (imho) clever, but also very awkward way of doing that.