/* https://github.com/BelfrySCAD/BOSL2 */ include track_tolerance = 2; // Additional space to the tracks' side to allow for better fit /* Brio variables, this file copies all Brio information rather than importing them */ track_width = 40 + track_tolerance; track_height = 12; track_well_depth = 2.9; track_well_width_top = 6.75; track_well_width_bottom = 4.75; track_well_spacing = 25.7; track_chamfer = 1.5; brio_track_plug_radius = 6; // 6.25 brio_track_plug_radius_ext = 6.25; // 6.5 for a dog-bone with springy plug brio_track_plug_neck_width = 6; // 6.1 brio_track_plug_neck_length = 18-brio_track_plug_radius; // 12 brio_track_plug_txt = "B"; brio_track_nest_radius = 6.5; // 6.4 brio_track_nest_neck_width = 7.3; // 6.3 brio_track_nest_neck_length = 18-brio_track_nest_radius; // 12 brio_track_nest_txt = "B"; track_plug_radius = brio_track_plug_radius; track_plug_radius_ext = brio_track_plug_radius_ext; track_plug_neck_width = brio_track_plug_neck_width; track_plug_neck_length = brio_track_plug_neck_length; track_plug_txt = brio_track_plug_txt; track_nest_radius = brio_track_nest_radius; track_nest_neck_width = brio_track_nest_neck_width; track_nest_neck_length = brio_track_nest_neck_length; track_nest_txt = brio_track_nest_txt; tr_wl_w_stick_out = (track_well_width_top-track_well_width_bottom)/2; tr_co_w = 0.75 * (track_well_spacing-track_well_width_top); cc = 0.001; switch_cut_ext = 1; bridge_height = 61; // Height below the track bridge_length = 144; side_width = 6; total_width = track_width + 2 * side_width; track_support_height = 3.5; // Thickness of the plank below the track track_support_overhang = 6; track_support_width = track_width + side_width; tunnel_rounding = 10; tunnel_width = track_width; // Double: 2 * track_width - track_tolerance + 6 tunnel_height = bridge_height + 3; $fn=150; // STRAIGHT TRACK GENERATOR MODULE module track(length = 144, end1 = "nest", end2 = "plug", part_chamfers = true, grooves = true, both_sides = false) { b = track_nest_neck_length + track_nest_radius; difference() { rotate([90, 0, 90]) linear_extrude(length) track_blueprint(grooves = grooves, part_chamfers = part_chamfers, both_sides = both_sides); if (end1 == "nest") { install_nest(nest_rotate = 0, length = 0); } if (end2 == "nest") { install_nest(nest_rotate = 180, length = length); } } //main difference // Generating plugs if (end1 == "plug") { install_plug(180, 0); } if (end2 == "plug") { install_plug(0, length); } } // Track shape blueprint module track_blueprint(grooves = true, both_sides = false, part_chamfers = true) { difference() { square([track_width, track_height]); // Corner champers if (part_chamfers) { part_chamfers(); } // Rail grooves if (grooves) if (both_sides) grooves(true); else grooves(false); } //difference } // Helping module used for generation of track grooves module grooves(both_sides = false) { for (x = [-track_well_spacing/2, track_well_spacing/2]) { translate([track_width/2+x, track_height-track_well_depth+cc, 0]) rail_well(); if (both_sides) { translate([track_width/2+x, track_well_depth-cc, 0]) rotate([0, 0, 180]) rail_well(); } } } // Helping function which defines a grove shape module rail_well() { translate([-track_well_width_bottom/2, 0, 0]) polygon([[0, 0], [track_well_width_bottom, 0], [track_well_width_bottom+tr_wl_w_stick_out, track_well_depth], [-tr_wl_w_stick_out, track_well_depth]]); } // Helping module for track() module - installs a plug module install_plug(plug_rotate = 180, length = 0) { translate([length, track_width/2, 0]) rotate([0, 0, plug_rotate]) track_plug(); } // Helping module for track() module - installs a nest module install_nest(nest_rotate = 180, length = 0) { translate([length, track_width/2, 0]) rotate([0, 0, nest_rotate]) track_nest(); translate([length, track_width/2, track_height/2 - cc]) rotate([0, 0, 45]) cube([track_nest_neck_width, track_nest_neck_width, track_height + 2*cc], center = true); } // Module track_plug() is used by multiple other modules for generating // a plug at a desired track ending module track_plug(radius = track_plug_radius, neck_w = track_plug_neck_width, neck_l = track_plug_neck_length){ translate([neck_l, 0, 0]) rotate([0, 0, 180]) { rotate_extrude(angle = 360) { polygon([[0, 0], [radius - track_chamfer/2, 0], [radius, track_chamfer/2], [radius, track_height - track_chamfer/2], [radius - track_chamfer/2, track_height], [0, track_height]]); } translate([0, -neck_w/2, 0]) cube([neck_l, neck_w, track_height]); } } // Module track_nest() is used by multiple other modules for generating // a nest at a desired track ending module track_nest(radius = track_nest_radius, neck_w = track_nest_neck_width, neck_l = track_nest_neck_length) { translate([neck_l-cc, 0, 0]) rotate([0, 0, 180]) { rotate_extrude(angle = 360) { polygon([[0, -cc], [radius + track_chamfer/2, -cc], [radius, track_chamfer/2], [radius, track_height - track_chamfer/2], [radius + track_chamfer/2, track_height + 2*cc], [0, track_height + 2* cc]]); } translate([0, -neck_w/2, -cc]) difference() { cube([neck_l, neck_w, track_height + 2*cc]); translate([0, 0, 0]) { } } } } module side() { translate([0,-side_width/2,bridge_height/2+track_height/2]) cuboid([bridge_length,side_width,bridge_height+track_height], chamfer=track_chamfer/sqrt(2), except=[TOP+BACK,TOP+LEFT,TOP+RIGHT,BACK+LEFT,BACK+RIGHT]); } difference() { group() { translate([-bridge_length/2,-track_width/2,bridge_height]) { track(length = bridge_length, end1 = "nest", end2 = "plug", part_chamfers = false, grooves = true, both_sides = false); // Plank below the track to support bridges on both sides translate([bridge_length/2,track_width/2,-track_support_height/2]) cuboid([bridge_length+2*track_support_overhang,track_support_width,track_support_height], chamfer=track_chamfer/sqrt(2)); } fwd(track_width/2) side(); rotate([0,0,180]) fwd(track_width/2) side(); } // Tunnel group() { // The +0.1 is a hack to fight some rendering issues in OpenSCAD up(tunnel_height/2) rotate([90,0,0]) cuboid([tunnel_width-2*tunnel_rounding,tunnel_height,total_width + 0.1], chamfer=-track_chamfer/sqrt(2), edges="X"); up(tunnel_height/2-tunnel_rounding/2) rotate([90,0,0]) cuboid([tunnel_width,tunnel_height-tunnel_rounding,total_width + 0.1], chamfer=-track_chamfer/sqrt(2), edges="Y"); translate([tunnel_width/2-tunnel_rounding,0,tunnel_height-tunnel_rounding]) ycyl(h=total_width + 0.1, r=tunnel_rounding, chamfer=-track_chamfer/sqrt(2)); translate([-(tunnel_width/2-tunnel_rounding),0,tunnel_height-tunnel_rounding]) ycyl(h=total_width + 0.1, r=tunnel_rounding, chamfer=-track_chamfer/sqrt(2)); } }