OpenSCAD
Maze Generation
This tutorial will show you how to use OpenSCAD Maze Generator, a python script developed by DNewman and derived from Eggbot's Maze generator, Eggmazing, distributed with the Eggbot software and is an Inkscape extension, that generates a random N x M maze and outputs a 3D description of it as an OpenSCAD program.
With DNewman's script you can control the number of maze cells and the maze's physical size with command line arguments. If you are comfortable with Python, you can modify the code to generate non-rectangular mazes by programming non-removable walls in the initialized maze data.
How do I make this?
- If you do not have OpenSCAD installed, download the application from openscad.org
- Download the maze.py Python script.
- Open your Terminal program.
- To check that Python is installed on your machine, type:
you should see something like this:
python
Press CTRL+Z or CTRL+D to exit Python.Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information.
If you are unfamiliar with python, here are a few things to keep in mind:- Python is not a typed language.
- Python is case sensitive.
- The end of a line marks the end of a statement.
- Single line comments begin with a #
- Multiline comments begin and end with '''
- Python source files use the .py extension.
- Navigate to where you have saved the maze.py script
- Run the script by typing:
The last argument, maze.scad, is the name of the output file to generate. The output is an OpenSCAD program which you can then load into OpenSCAD and render. If no name is supplied, then the OpenSCAD program is written to standard output, stdout.
python maze.py maze.scad
- To view the command line arguments type:
You should see something like this:
python maze.py --help
So if you wanted a 10 x 8 maze you would type the following at the prompt:Usage: maze.py [-cfhlrtw] [output-file] -c, --columns Number of maze columns running the maze width (default = 8) -f, --floor Physical thickness in millimeters of the maze floor (default = 2.000000) -h, --height Physical height in millimeters of the maze (default = 8.000000) -l, --length Physical length in millimeters of the maze (default = 30.000000) -r, --rows Number of maze rows running the maze length (default = 8) -t, --thickness Physical maze wall thickness in millimeters (default = 0.375000) -w, --width Physical width in millimeters of the maze (default = 30.000000) output-file Name of the output file to generated; if not specified then output will be written to standard output
python maze.py -c 10
- Double click on the scad file the code output to open the maze in OpenSCAD
- To display the axes in the model view press Command+2 (MAC) or CTRL+2 (Windows and Linux).
- View the maze by pressing F5
- Render and Compile by pressing F6. Then select Design>Export as STL
- Open the STL file in Makerware and prepare the file for printing.
Why am I doing this?
Python is a programming language that lets you work more quickly and integrate your systems more effectively.Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines.
Python is free to use, even for commercial products.
OpenSCAD allows you to program parametrically. By following this tutorial, you should be able to generate several variations of mazes quickly and easily.
Now what?
- Upload your maze to Thingiverse
- Come back tomorrow for more information and inspiration!