A-Mazing Box

by wizard23, published

A-Mazing Box by wizard23 Dec 23, 2009

Featured Thing!

Thing Info

41332Views 13986Downloads Found in Interactive Art
Report Thing


A python script to generate OpenSCAD models to generate two parts of a box that screw together and snap fit if you find your way through the maze :)

UPDATE: because I got so many requests from people I now offer printed versions for sale at: http://www.hackerspaceshop.com/3dprinting/a-mazing-box.html
contact me for custom mazes :)


Actually the maze pattern comes from the attached greyscale png :)

To regenerate the model adapt the png filename and the variable "part" in mazebox_clean2_stable.py (1 == bottom part, 2 == top part)

The png must be grayscale without an alpha channel.

The python script is a mess but I needed to get this done before xmas... Also sorry for the weird filenames, but thingiverse does not let me rename files...

The model was intended to have exact 1.5mm wall thickness when intersected with a plane parallel to the XY-plane (to get skeinforged into 2 layers) but the 3D inset operation is tricky so it sometimes is a little less but the repraped parts are still very stable after my makerbot printed for two hours :)

More from Interactive Art

view more

Thing Info

41332Views 13986Downloads Found in Interactive Art
Report Thing

Liked By

View All


Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

All Apps

This extension connects Thingiverse with Makeprintable, a cloud-based mesh repair service that analyzes, validates and repairs most common mesh errors that can occur when preparing a 3D design file...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

You should make increased difficulty puzzles and they should be bigger tubes

why did you write a python script to export a point and triangle list to put into a openscad file? Why not export directly to stl?

I don't see the .png file that defines the maze. Is it hidden somehow, or is it missing?

Awesome love it looks awesome thanks for making it.

You should make it so that there's no indent where the bump is so that its harder

that is quite easy to fix just look at the smaller openscad file and comment out the outher 3 sheres that get cut away (the last three)

I got it! thanks for your help!

maybe you could post that for me? thanks!

Which file?

what program did u use to make it

python and openscad the python program is attached

The source is really really broken in all the current tools.

If you can make a PNG that the python tools are happy with (the original got converted to a jpg by thingiverse BTW), it compiles with the maze too low on the model and renders to a thin flat disc.

One I hacked to have the maze in the right place on the compile renders better, but is clipped at about 15mm on the render.

:-( Any clues?

Yes the code is broken. The problem you describe happens because you have to adapt the number of pixels (height and width) that you want to use in the source code. It was a quick hack but the code is there and this is quite easy to fix just look at the first few python lines. maybe i'll find some time to do that during the holidays ;)

In the end I just hacked the hack, I could get just one of the polysets to export as STL, then I managed to just model the base from there.

These look like they would make great geocache containers :)

this is exactly what i was going to print these for :D more specifically this one http://www.thingiverse.com/thing:4098http://www.thingiverse.com/thi... :)

Super PI Box

I love functional puzzles. I use mine to keep the pieces of my George Hart's 12 Stick Puzzle in. The lid goes about 2/3 of the way down and locks nicely. It's just a brilliant design and never easy to open.

Judging from the maze in your picture, you built my derivative Thing http://www.thingiverse.com/thing:6004http://www.thingiverse.com/thi... in which I had swapped the wrong-turns and right-turns as much as I could. (Compare the pictures carefully and you'll see the differences.)

I encourage you to build both versions and compare whether the derivative maze is harder, easier, or just different!

A-Mazing Box Detour

Anytime I try to compile the python generated model with openscad, even the sample, after an interminable compilation duration more appropriate for last century, openscad crashes with an obscure error.

terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: itl != it-

File: /usr/include/CGAL/Nef_3/SNC_external_structure.h

Line: 1088


If you have gotten openscad to compile the python generated program, can you tell me what version of openscad you are using?


oh sorry that happens when you have too sharp corners in the gray scale image and the inset algorithm screws up...either fix the inset code or add some gray scale gradient to avoid sharp cornered small lines that get inset weird...i still love this box idea and hope to find some time to fix the inset code to get rid of these excepion for real but its a little tricky maybe it would be better to uses some existing 2d library for the inset because basic inset is almost trivial (some 2d linear equations need to be solved) but the cornercases complicate everything and well I did not manage the first time I tried...maybe the community is faster than me? ;)

I intermittently encountered the same error, plus occasional winding errors, when I tried to repair my derivative. The errors go away if you * disable the second polyhedron, but I can't see anything wrong with the Python script that generates it.

Eventually I found a workaround by deleting the second polyhedron and replacing it with a copy of the first polyhedron prefixed with "translate([0,0,0.01]) scale([0.94,0.94,1.0]) " to cut out the hollow interior and offset it very slightly to avoid manifold errors. This gives approximately the sa
me 1.5mm wall thickness as the original Python output.

Another workaround is to delete the second polyhedron with "cylinder(h=80, r=23.4 );" to build a smooth interior wall. That gives a model whose walls vary from 1.5mm to 3.0mm in thickness due to the contours of the maze.

@VeryWetPaint these are two very good solutions. maybe I overcomplicated it by trying to inset it. My goal was back then to have a constant wall thickness so that it would always extrude exactly 2walls for the whole labyrinth. but now that the printing quality increased so much by using a stepper based extruder this workaround is no longer needed and a scaled version on the inside works just as well and should also speed up the openscad rendering time :)

Have you though about adding knurled ends?

I have trouble gripping the 2 ends!

excellent idea...you are right they ARE hard to grip and printed knurled things look amazingly beautiful. I was never really satisfied with the boring cylindrical surface.

I might actually do this next xmas...but maybe the community is faster than me ;)

Having some problems with getting the outer sleeve made as a more solid unit. Changing the infill property doesn't seem to affect it still being built as an inner and outer sleeve that's not very stiff. Any ideas please?

Set extra shells to 0 in the Fill module.

would it be really hard to connect all three of the mazes to make one big one that wraps all the way around the part?

no just adapt the pixel image you feed to the python script. it warps around 3 times the way the python code is now but this is a number you can modify just like the picture :)

hi Wizard!

thx allot for printing me this amazing showcase-Box 8-)

cya ;)

Awesome design. When I have time I'll try the scripts - printed out the example though!

Was a very tight fit - thank goodness I just installed twotime's z-axis wobble arrest or the path's would have been too bumpy to work smoothly.

I did sand off the z-axis ridges on the "knobs" on the top so it wouldn't have little ridges rubbing ridges.

Thanks for the excellent work!

on my makerbot it took about 50 minutes to print the larger and 40 minutes to print the smaller part...

how exactly do you use the script? i put all the files into 1 folder. after reading http://mazebox_clean2_stable.pymazebox_clean2_stable.py i put the png in the playground folder but running http://mazebox_clean2_stable.pymazebox_clean2_stable.py just opens a command window for a second then it closes.

run it in the command line like this (I think this should even work under windows although I only tested it under ubuntu):
python mazebox clean2 http://stable.pystable.py
gt; myBox.scad

You might want to adapt the variables (in the python code):

  • "rn" (three times the x resolution of the image),
  • "hn" (the y resolution of the image)
  • "depth" (the image file)
  • "part" (which part to generate)

It's a little bit messy because I had to finish this in time for xmas and did not clean it up afterwards...anyway if there are more questions please ask :)

Started printing this today on my school's starch and glue based printer, tomorrow I'll see if the thin walls are strong enough on this type of printer.

jon - in reply to jon

It worked alright. I'm guessing that the plastic parts shrink a little because my starch print didn't fit together until I sanded and filed it a little.

Printed on 0.25mm layer-height on a RepMan.

Wow, this is absolutely brilliant! :D
I want one! Must find a source of plastic in Ireland, I'm getting sick of being frugal with ABS..

Where do I get the missing http://testpng.pytestpng.py file?

I forgot it in the first place but II uploaded it now

Sweet! I knew something like this was on its way when saw your first lockbox :) Nice work!

thanks! in the xmas holidays i want to try out many new boxes with different patterns form other images...once it's programed it can be executed may times..the joy of parametric modeling ;)

OMG so awesome!