I’ve been experimenting with OpenSCAD for some time and was building some plates to attach some components together. For these I needed a rounded corner rectangle with some regularly spaced holes. I knew that you could create module functions that generate objects but I’d not realised that there was a second type which acted on objects, called an operator module.

To create my rounded rectangle I take four cylinders and act on them with the hull function. This turns them into a single object, with rounded corners. Originally I had the cylinder repeated 4 times with different translates. But after reading I realised that I could do that in code too.

To produce my four cylinders I’ve created an operator module which repeats any children of the function over a rectangular array. Looking back the the previous function we can see that a cylinder is passed in as the child object. So these operator modules are good for repeating or arranging items.