OpenSCAD

Maze Generation

DSC_0029_preview_featured.jpg


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?

  1. If you do not have OpenSCAD installed, download the application from openscad.org


  2. Download the maze.py Python script.


  3. Open your Terminal program.


  4. To check that Python is installed on your machine, type:
    python
    you should see something like this:
        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.
    Press CTRL+Z or CTRL+D to exit Python.

    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.

  5. Navigate to where you have saved the maze.py script


  6. Run the script by typing:
    python maze.py maze.scad
    
    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.


  7. To view the command line arguments type:
    python maze.py --help
    
    You should see something like this:
    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
    
    So if you wanted a 10 x 8 maze you would type the following at the prompt:
     python maze.py -c 10



  8. Double click on the scad file the code output to open the maze in OpenSCAD


  9. To display the axes in the model view press Command+2 (MAC) or CTRL+2 (Windows and Linux).



  10. View the maze by pressing F5


  11. Render and Compile by pressing F6. Then select Design>Export as STL


  12. 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?

  1. Upload your maze to Thingiverse
  2. Come back tomorrow for more information and inspiration!