2013-05-24 11:29:51 -05:00
/*********************************
* OpenSCAD GridBeam Library *
* ( c ) Timothy Schmidt 2013 *
* http : //www.github.com/gridbeam *
* License : LGPL 2.1 or later *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/* Todo:
- implement "dxf" mode
2011-01-04 22:23:09 -06:00
* /
// zBeam(segments) - create a vertical gridbeam strut 'segments' long
// xBeam(segments) - create a horizontal gridbeam strut along the X axis
// yBeam(segments) - create a horizontal gridbeam strut along the Y axis
2013-05-24 11:29:51 -05:00
// zBolt(segments) - create a bolt 'segments' in length
// xBolt(segments)
// yBolt(segments)
2011-01-05 16:42:10 -06:00
// topShelf(width, depth, corners) - create a shelf suitable for use in gridbeam structures width and depth in 'segments', corners == 1 notches corners
// bottomShelf(width, depth, corners) - like topShelf, but aligns shelf to underside of beams
// backBoard(width, height, corners) - create a backing board suitable for use in gridbeam structures width and height in 'segments', corners == 1 notches corners
// frontBoard(width, height, corners) - like backBoard, but aligns board to front side of beams
2011-01-04 22:23:09 -06:00
// translateBeam([x, y, z]) - translate gridbeam struts or shelves in X, Y, or Z axes in units 'segments'
2013-05-24 11:29:51 -05:00
// To render the DXF file from the command line:
// openscad -x connector.dxf -D'mode="dxf"' connector.scad
mode = "model" ;
//mode = "dxf";
include < MCAD/units.scad >
2011-01-04 22:23:09 -06:00
2013-05-24 11:29:51 -05:00
beam_width = inch * 1.5 ;
beam_hole_radius = inch * 5 / 16 ;
beam_is_hollow = 1 ;
beam_wall_thickness = inch * 1 / 8 ;
beam_shelf_thickness = inch * 1 / 4 ;
2011-01-04 22:23:09 -06:00
module zBeam ( segments ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
2011-01-04 22:23:09 -06:00
difference ( ) {
2013-05-24 11:29:51 -05:00
cube ( [ beam_width , beam_width , beam_width * segments ] ) ;
2011-01-04 22:23:09 -06:00
for ( i = [ 0 : segments - 1 ] ) {
2013-05-24 11:29:51 -05:00
translate ( [ beam_width / 2 , beam_width + 1 , beam_width * i + beam_width / 2 ] )
2011-01-04 22:23:09 -06:00
rotate ( [ 90 , 0 , 0 ] )
2013-05-24 11:29:51 -05:00
cylinder ( r = beam_hole_radius , h = beam_width + 2 ) ;
2011-01-04 22:23:09 -06:00
2013-05-24 11:29:51 -05:00
translate ( [ - 1 , beam_width / 2 , beam_width * i + beam_width / 2 ] )
2011-01-04 22:23:09 -06:00
rotate ( [ 0 , 90 , 0 ] )
2013-05-24 11:29:51 -05:00
cylinder ( r = beam_hole_radius , h = beam_width + 2 ) ;
2011-01-04 22:23:09 -06:00
}
2013-05-24 11:29:51 -05:00
if ( beam_is_hollow = = 1 ) {
translate ( [ beam_wall_thickness , beam_wall_thickness , - 1 ] )
cube ( [ beam_width - beam_wall_thickness * 2 , beam_width - beam_wall_thickness * 2 , beam_width * segments + 2 ] ) ;
2011-01-04 22:23:09 -06:00
}
}
2013-05-24 11:29:51 -05:00
}
if ( mode = = "dxf" ) {
}
}
2011-01-04 22:23:09 -06:00
module xBeam ( segments ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
translate ( [ 0 , 0 , beam_width ] )
2011-01-04 22:23:09 -06:00
rotate ( [ 0 , 90 , 0 ] )
zBeam ( segments ) ;
}
2013-05-24 11:29:51 -05:00
if ( mode = = "dxf" ) {
}
}
2011-01-04 22:23:09 -06:00
module yBeam ( segments ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
translate ( [ 0 , 0 , beam_width ] )
2011-01-04 22:23:09 -06:00
rotate ( [ - 90 , 0 , 0 ] )
zBeam ( segments ) ;
}
2013-05-24 11:29:51 -05:00
if ( mode = = "dxf" ) {
}
}
module zBolt ( segments ) {
if ( mode = = "model" ) {
}
if ( mode = = "dxf" ) {
}
}
module xBolt ( segments ) {
if ( mode = = "model" ) {
}
if ( mode = = "dxf" ) {
}
}
module yBolt ( segments ) {
if ( mode = = "model" ) {
}
if ( mode = = "dxf" ) {
}
}
2011-01-04 22:23:09 -06:00
module translateBeam ( v ) {
for ( i = [ 0 : $children - 1 ] ) {
2013-05-24 11:29:51 -05:00
translate ( v * beam_width ) child ( i ) ;
2011-01-04 22:23:09 -06:00
}
}
2011-01-05 16:42:10 -06:00
module topShelf ( width , depth , corners ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
2011-01-04 22:23:09 -06:00
difference ( ) {
2013-05-24 11:29:51 -05:00
cube ( [ width * beam_width , depth * beam_width , beam_shelf_thickness ] ) ;
2011-01-05 16:42:10 -06:00
if ( corners = = 1 ) {
2011-01-04 22:23:09 -06:00
translate ( [ - 1 , - 1 , - 1 ] )
2013-05-24 11:29:51 -05:00
cube ( [ beam_width + 2 , beam_width + 2 , beam_shelf_thickness + 2 ] ) ;
translate ( [ - 1 , ( depth - 1 ) * beam_width , - 1 ] )
cube ( [ beam_width + 2 , beam_width + 2 , beam_shelf_thickness + 2 ] ) ;
translate ( [ ( width - 1 ) * beam_width , - 1 , - 1 ] )
cube ( [ beam_width + 2 , beam_width + 2 , beam_shelf_thickness + 2 ] ) ;
translate ( [ ( width - 1 ) * beam_width , ( depth - 1 ) * beam_width , - 1 ] )
cube ( [ beam_width + 2 , beam_width + 2 , beam_shelf_thickness + 2 ] ) ;
2011-01-05 16:42:10 -06:00
}
2011-01-04 22:23:09 -06:00
}
2011-01-05 16:42:10 -06:00
}
2013-05-24 11:29:51 -05:00
if ( mode = = "dxf" ) {
}
}
2011-01-05 16:42:10 -06:00
module bottomShelf ( width , depth , corners ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
translate ( [ 0 , 0 , - beam_shelf_thickness ] )
2011-01-05 16:42:10 -06:00
topShelf ( width , depth , corners ) ;
}
2013-05-24 11:29:51 -05:00
if ( mode = = "dxf" ) {
}
}
2011-01-05 16:42:10 -06:00
module backBoard ( width , height , corners ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
translate ( [ beam_width , 0 , 0 ] )
2011-01-05 16:42:10 -06:00
difference ( ) {
2013-05-24 11:29:51 -05:00
cube ( [ beam_shelf_thickness , width * beam_width , height * beam_width ] ) ;
2011-01-05 16:42:10 -06:00
if ( corners = = 1 ) {
translate ( [ - 1 , - 1 , - 1 ] )
2013-05-24 11:29:51 -05:00
cube ( [ beam_shelf_thickness + 2 , beam_width + 2 , beam_width + 2 ] ) ;
translate ( [ - 1 , - 1 , ( height - 1 ) * beam_width ] )
cube ( [ beam_shelf_thickness + 2 , beam_width + 2 , beam_width + 2 ] ) ;
translate ( [ - 1 , ( width - 1 ) * beam_width , - 1 ] )
cube ( [ beam_shelf_thickness + 2 , beam_width + 2 , beam_width + 2 ] ) ;
translate ( [ - 1 , ( width - 1 ) * beam_width , ( height - 1 ) * beam_width ] )
cube ( [ beam_shelf_thickness + 2 , beam_width + 2 , beam_width + 2 ] ) ;
2011-01-05 16:42:10 -06:00
}
}
}
2013-05-24 11:29:51 -05:00
if ( mode = = "dxf" ) {
}
}
2011-01-05 16:42:10 -06:00
module frontBoard ( width , height , corners ) {
2013-05-24 11:29:51 -05:00
if ( mode = = "model" ) {
translate ( [ - beam_width - beam_shelf_thickness , 0 , 0 ] )
2011-01-05 16:42:10 -06:00
backBoard ( width , height , corners ) ;
2013-05-24 11:29:51 -05:00
}
if ( mode = = "dxf" ) {
}
}