The difference() modifier will subtract the children of the object, from the first item in the modifier brackets.
Let’s start by subtracting a sphere from a cube. First add a cube
cube(5);
Add a sphere
sphere(5);
Now place a difference() modifier in front of the cube, and press f5
difference() cube(5); sphere(5);
Nothing Happens! With the Set Modifiers ( boolean in OpenSCAD lingo. The children being operated on must be inside Curly Brackets.
difference() { cube(5); sphere(5); }
Press F9 to change to Preview Mode and F5 to Render
With the difference modifier every child after the first is subtracted from the first. In this case sphere is subtracted from cube