Activity A.1. Create a Square in OpenSCAD

Activity A.1. Create a Square in OpenSCAD

This activity creates a square 25 mm (about an inch) on a side. All the activities here assume that OpenSCAD is open and working, and that you have launched it with the usual graphical user interface. 

Steps: 

square(25);

A square, file square25.svg

You will note that there is a semicolon at the end of the command. OpenSCAD uses a programming language that is sort of like the C, Python or Java programming languages, with some quirks. You can do a lot by bearing just a few rules in mind which we will describe in later activities. For now, just think of it that any 2D object description needs to end in a semicolon.

Also, OpenSCAD uses three different types of parentheses or brackets that mean different things. Make sure you follow our examples exactly. This simple example uses just parentheses; others will use square or curly brackets. 

Tip: Troubleshooting

If the square doesn’t show up, this is a good time to reinforce that coding is precise and predictable. Oftentimes things don’t show up as planned due to a syntax error. Have your student read back their code, character by character, this verbal check will help you find syntax issues.

Continuing on with the steps to create our SVG showing a square:

Rendering and Exporting an SVG 

The file ending in .scad can be edited in OpenSCAD going forward. (SVG files can be opened in OpenSCAD, but not edited.) Now that we have saved the file we can try rendering, exporting and printing it. 

Activity 2 and 3 have the same workflow. You will just be typing different things into the editor.

Teaching Tip: Editing SVGs

Existing SVG files can be imported into OpenSCAD, as described on the OpenSCAD manual "SVG Import" page. However, they can not be edited per se. Technically they can be combined with other shapes, but this is very case-dependent and not recommended. Shapes generated by OpenSCAD are shown with a solid outline and a light grey fill, as we show in this document. There are no options to change it in OpenSCAD itself.