/** * A keychain based of Corona688 great OpenSCAD Maze at * http://www.thingiverse.com/thing:595481 */ // maze parameters rows=20; columns=32; // was sectors in original cell_width=2.0; wall_width=1.0; // plate parameters base_height=1; notch_depth=1; // lug parameters build_lug=true; //set to false if no lug is desired hole_diameter=4.0; lug_diameter=hole_diameter+3.0; entire_height=base_height+notch_depth; // entry keychain height // don't forget to set the maze here! maze_keychain(m_Corona688_scad); // Maze generator which takes ASCII art // It takes 14x8 mazes, which amount to // 32 x 20 ASCII art. m_Corona688_scad=[ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ "############### ################", "# # # # # # # ", "### # ##### # # # ### # ### # # ", "# # # # # # # # # # ", "# # ##### # ### ### # ### ### # ", "# # # # # # # # ", "# ######### ##### # ### ### ### ", "# # # # # ### # # ", "### # # # ### ####### ### ##### ", " # # # # # # # # ", "# ##### # # # # # # # # # ### ##", "# # # # # # # # # ", "# ####### # # ##### # ##### # ", "# # # # # # # # # # # ", "### # ##### ### # # # # # # # ##", "# # # # # # # # #", "# ### ######### ##### ### ### ##", " # # # # # # # # ", "# # # # ### # ### ####### # ### ", "# # # # # # *# ", // put an asterisk (*) to mark the start point // "################################", ]; m_Corona688_scad_old=[ "################### ############", "# ### # # # # # # ", "# ### ### # ### # ### ### # # # ", "# # # # # # # ", "##### ########### ### ### # # # ", "### # # # # # # ", "# ####### ### # # ### # # ### ##", "# # # # # # # # # # # ##", "# ######### # ### # ### ### ####", " # ### # # # # ", // connects around to left side "# ### ### ##### ####### ### # # ", "# # # ### # # # # # # # ", "# # # ##### ##### ##### # ### ##", "# # # # # # ", "# ######### ####### ### ### # # ", " ### # # # # ### # # ", // Connects around to other side "# ########### # # ### # ##### # ", "# # # # ### # ", "# ### # ### ####### # # ##### ##", " *# # # # # # #", // "################################", ]; m_Corona688_scad_stl=[ /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ "############### ################", "# # # # # # # ", "### # ##### # ### ### # ### # # ", "# # # ### # # # # # ", "# # ##### # ####### # ### ### # ", "# # # # # # # # ", "# ######### ##### # ### ### ### ", "# # # # # ### # # ", "### # # # ### ####### ### ##### ", " # # # # # # # # ", "# ##### # # # # # # # # # ### ##", "# # # # # # # # # ", "# ####### # # ##### # ##### # ", "# # # # # # # # # # # ", "### # ##### ### # # # # # # # ##", "# # # # # # # # #", "# ### ######### ##### ### ### ##", " # # # # # # # # ", "# # # # ### # ### ####### # ### ", "# # # # # # *# ", // put a asterisk to mark the start point // "################################", ]; module maze_keychain(m) union() { difference() { // build plate hull() for(x=[wall_width,columns/2*(cell_width+wall_width)],y=[wall_width,rows/2*(cell_width+wall_width)]) translate([x,y,0]) union() { cylinder(r1=wall_width+notch_depth,h=base_height,$fn=20); translate([0,0,base_height]) cylinder(r1=wall_width+notch_depth,r2=wall_width,h=notch_depth,$fn=20); } // mill maze translate([0,0,base_height]) union() for(x=[0:columns],y=[0:rows]) assign(cell_value=m[rows-y][x]) assign(x0=floor(x/2)*(cell_width+wall_width)+(x%2>0?wall_width:0)) assign(x1=(x%2>0?cell_width:wall_width)) assign(y0=floor(y/2)*(cell_width+wall_width)+(y%2>0?wall_width:0)) assign(y1=(y%2>0?cell_width:wall_width)) assign(y1=(y==rows?2*wall_width:y1)) // special handling for top row to render exit correctly assign(x0=(x==0?x0-wall_width:x0)) // special handling for 1st and last columns to render sideways correctly assign(x1=(x==0||x==columns?2*wall_width:x1)) // special handling for 1st column to render sideways correctly translate([x0,y0,0]) if(cell_value==" ") { cube([x1,y1,notch_depth+0.1]); } else if(cell_value=="*") { difference() { cube([x1,y1,notch_depth+0.1]); translate([1,1,0]*cell_width/2) cylinder(d1=cell_width,d2=cell_width/2,h=notch_depth/2,$fn=4); } } } // build lug if(build_lug) translate([-1,-1,0]*hole_diameter/2) assign(height=(entire_height+base_height)/2) difference() { cylinder(d=lug_diameter,h=height,$fn=30); cylinder(d=hole_diameter,h=height+0.1,$fn=30); } }