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:
- Go to the File menu, and select New File.
- Navigate to the Editor window.
- In the Editor window, type:
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:
- In the main Menu bar along the top, select Save and give the model an appropriate name ending in .scad, like square.scad.
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.
- In the Design menu, click Render. This creates an exportable version of the file.
- In the File menu, select Export and then Export as SVG.
- The file should now be exported to a location you specify and ready for tactile printing. It should produce a square 25 mm on a side (just under an inch).
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.