Ever need a maze generated for OpenSCAD? If so, then this puppy is for you. It is a Python script which generates a random N x M maze and outputs a 3D description of it as an OpenSCAD program.
The number of maze cells as well as the maze's physical size can all be controlled with command line arguments when running the Python script. The Python code can even be modified to generated non-rectangular mazes. (Hint: just throw up non-removable walls in the initialized maze data.)
BTW, the Python code here is derived from the Eggbot Maze generator, Eggmazing, which is distributed with the Eggbot software and is an Inkscape extension. I wrote that extension for the Eggbot in the Fall of 2010 and want to again thank W. Craig Trader for the assistance he provided with that effort.
9 June 2012: Corrected invalid commenting style in line 1 of OpenSCAD output
9 June 2012: Added warning when wall thickness (-t) is explicitly set to be thicker than one-half the cell's width or length.
Download the maze.py Python script and run it,
% python maze.py maze.scad
where 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. Use whatever file name suits your fancy. If no name is supplied, then the OpenSCAD program is written to standard output, stdout.
The command line arguments can be seen with the command
% python maze.py --help
Usage: maze.py [-cfhlrtw] [output-file]
Number of maze columns running the maze width (default = 8)
Physical thickness in millimeters of the maze floor (default = 2.000000)
Physical height in millimeters of the maze (default = 8.000000)
Physical length in millimeters of the maze (default = 30.000000)
Number of maze rows running the maze height (default = 8)
Physical maze wall thickness in millimeters (default = 1.000000)
Physical width in millimeters of the maze (default = 30.000000)
Name of the output file to generated; if not specified then
output will be written to standard output
The two attached .stl files, maze-8x8.stl and maze-10x10.stl, were both generated with this script.