EDIT 1 (3/24/15): Added dual extrusion support.
EDIT 2 (3/24/2015): Added option to have entrance and exits closed, also added setting to make 2D vector path instead of 3D mesh. Fixed minor redundancy in code.
EDIT 3 (3/25/15): Fixed minor settings conflict, added more comments for clarity.
A search on Thingiverse led me to a Python script that generated an OpenSCAD description of a maze, but that seemed too round-about for me. Besides, I like the looks of the classic recursive-backtracker algorithm more than any other, and it's so deliciously simple to implement. Also, I really, really like generating mazes. :) So, I decided to write my own.
Initially, I wanted to implement it in OpenSCAD, but because it uses a functional language, determined that it was impossible. (Apparently I was totally wrong!) However, I finally got it working as a Python script within Blender.
This took about a year or so of very sparse tinkering. Initially, I was trying to use booleans to add and subtract cuboids (like OpenSCAD), but that proved problematic due to the finicky nature of normals and stuff. So, I wound up making the maze as a 2D mesh (vertex by vertex, face by face), then extruding it and adding the base later.
This is fully functional, but there are a few features I still want. I really want to be able to mark the start and end, but I'm not sure how I should do it. Leave a comment and give me your ideas!
For fun, the
20x20_humanSize.stl is a 20 X 20 maze that would be suitable for a human to walk around in. (62600 mm x 626000 mm total, or about 98.6 acres). Here are the settings: (thanks, Google!)
width = 20 #how many cells wide
length = 20 #how many cells long
cellThickness = 2500 #width of passages [mm]
wallThickness = 600 #width of walls [mm]
wallHeight = 2500 #height of walls [mm]
baseHeight = 300 #height of base [mm]
Good luck printing that at 1:1 scale.
To make your own maze, download
Maze Generator.blend, open it in Blender, and read the instructions in the script in the upper left. When it's done, select it, then File>Export>Stl (.stl). Print and enjoy! No supports needed!
I would recommend the wall width to be a multiple of your nozzle diameter so you can print them solid using only shells. For example, if you have a nozzle that's 0.4 mm, you can print the walls solidly using 1 shell (which will make the walls 2 shells thick total) if they are 0.4*2 mm thick.
Alternatively, you can laser cut them! Support for this is limited ATM, but if you set the
wallHeight = 0, it will make a path (really, 2 paths) instead of a mesh. Use the Blender SVG Exporter to get it as an SVG and make whatever you want out of it! Of course, it's not fit to laser cut right out of the box, you have to get creative with it! (If you use Inkscape, scale the paths by 125% before using them. Illustrator works as-is.)
The files for the laser cut ball maze are
15x15_ball_maze.svg. Instructions are inside the files.
If you make your own 3D or laser cut designs from this project, please credit me, and add it as a remix to this thing.
Instead of using the .blend file, you could also load the
blender_maze_gen.py up in blender on your own, but there's not much reason to do this IMO. Just use the .blend file.
Currently, the entrance and exit look the same. The entrance is the hole that will face towards you when printed (or the one in the 3rd quadrant [-x, -y], for those who want to be specific). Comment to give me ideas for how to mark them, because I'm at a loss.