# HG changeset patch # User Paul Boddie # Date 1412701996 -7200 # Node ID 7f0bd49f19127b0fe03fda9574bdf9734d23a4c1 # Parent f6f352022ef4a88145c1ce73703fa641166748ac Added configuration options for separating the pieces and omitting features. diff -r f6f352022ef4 -r 7f0bd49f1912 cartridge.scad --- a/cartridge.scad Tue Oct 07 18:30:46 2014 +0200 +++ b/cartridge.scad Tue Oct 07 19:13:16 2014 +0200 @@ -26,6 +26,10 @@ TOP_LABEL_INSET = 1; GROOVE = 1; + BACK = 1; BACK_SURFACE = 1; + FRONT = 1; FRONT_SURFACE = 1; + APART = 1; + /* Rounding/fillet radius and additional margin of subtracted material. The additional margin helps avoid geometry problems. @@ -359,364 +363,380 @@ /* The actual shapes. */ - translate([-width * 0.6, 0, 0]) - difference() { + front_displacement = APART ? -width * 0.6 : 0; + + if (FRONT) + translate([front_displacement, 0, 0]) + difference() { - /* The cartridge surfaces. */ + /* The cartridge surfaces. */ - union() { + union() { - /* Front portion. */ + /* Front portion. */ - translate([0, -front_depth + front / 2, 0]) - cube([width, front, height], center = true); - translate([-width / 2 + front_left / 2, -front_depth / 2, 0]) - cube([front_left, front_depth, height], center = true); - translate([width / 2 - front_right / 2, -front_depth / 2, 0]) - cube([front_right, front_depth, height], center = true); - translate([0, -front_depth / 2, height / 2 - top / 2]) - cube([width, front_depth, top], center = true); - difference() { + if (FRONT_SURFACE) { + cube_at(width, front, height, + 0, -1, 0, + 0, -int_front_depth, 0); + cube_at(front_left, front_depth, height, + -1, -1, 0, + -int_width / 2, 0, 0); + cube_at(front_right, front_depth, height, + 1, -1, 0, + int_width / 2, 0, 0); + cube_at(width, front_depth, top, + 0, -1, 1, + 0, 0, int_payload_upper_extent); + } - /* Floor of cartridge. */ + difference() { + + /* Floor of cartridge. */ + + cube_at(width, front_depth, bottom, + 0, -1, 1, + 0, 0, -height / 2 + int_connector_height); + + /* Left cutout. */ - cube_at(width, front_depth, bottom, - 0, -1, 1, - 0, 0, -height / 2 + int_connector_height); + cube_at(edge_connector_cutout_front_width, + edge_connector_cutout_front_depth, + bottom, + 1, -1, 1, + -width / 2 + edge_connector_cutout_front_offset, + 0, + -height / 2 + int_connector_height); + + /* Right cutout. */ - /* Left cutout. */ + cube_at(edge_connector_cutout_front_width, + edge_connector_cutout_front_depth, + bottom, + -1, -1, 1, + width / 2 - edge_connector_cutout_front_offset, + 0, + -height / 2 + int_connector_height); + } + + /* PCB supports. */ - cube_at(edge_connector_cutout_front_width, - edge_connector_cutout_front_depth, - bottom, - 1, -1, 1, - -width / 2 + edge_connector_cutout_front_offset, - 0, - -height / 2 + int_connector_height); + cube_at(pcb_front_support_width, + pcb_front_support_depth, + pcb_front_support_height, + 1, -1, 1, + -edge_connector_cutout_back_width / 2 + + pcb_support_margin, + 0, + -height / 2 + bottom + int_connector_height); - /* Right cutout. */ + cube_at(pcb_front_support_width, + pcb_front_support_depth, + pcb_front_support_height, + -1, -1, 1, + edge_connector_cutout_back_width / 2 - + pcb_support_margin, + 0, + -height / 2 + bottom + int_connector_height); - cube_at(edge_connector_cutout_front_width, - edge_connector_cutout_front_depth, - bottom, - -1, -1, 1, - width / 2 - edge_connector_cutout_front_offset, - 0, - -height / 2 + int_connector_height); + /* Circular "lugs" to hold PCBs in place. */ + + pcb_front_lug(-1); + pcb_front_lug(1); } - /* PCB supports. */ + /* Label insets. */ + + union() { + + /* Front label. */ - cube_at(pcb_front_support_width, - pcb_front_support_depth, - pcb_front_support_height, - 1, -1, 1, - -edge_connector_cutout_back_width / 2 + - pcb_support_margin, - 0, - -height / 2 + bottom + int_connector_height); - - cube_at(pcb_front_support_width, - pcb_front_support_depth, - pcb_front_support_height, - -1, -1, 1, - edge_connector_cutout_back_width / 2 - - pcb_support_margin, - 0, - -height / 2 + bottom + int_connector_height); + if (FRONT_LABEL_INSET) + translate([-front_label_width / 2, -front_depth, + front_label_offset_from_bottom - height / 2]) + cube([front_label_width, front_label_depth, + front_label_height]); - /* Circular "lugs" to hold PCBs in place. */ - - pcb_front_lug(-1); - pcb_front_lug(1); - } - - /* Label insets. */ - - union() { + /* Top label. See also the back piece. */ - /* Front label. */ + if (TOP_LABEL_INSET) + translate([-top_label_width / 2, + -front_depth + top_label_offset_from_front, + height / 2 - top_label_depth]) + cube([top_label_width, top_label_height, + top_label_depth]); + } - if (FRONT_LABEL_INSET) - translate([-front_label_width / 2, -front_depth, - front_label_offset_from_bottom - height / 2]) - cube([front_label_width, front_label_depth, - front_label_height]); - - /* Top label. See also the back piece. */ + /* Inner front edge cavity. */ - if (TOP_LABEL_INSET) - translate([-top_label_width / 2, - -front_depth + top_label_offset_from_front, - height / 2 - top_label_depth]) - cube([top_label_width, top_label_height, - top_label_depth]); - } - - /* Inner front edge cavity. */ + translate([inner_front_edge_width / 2, -int_front_depth, -height / 2]) + rotate([0, -90, 0]) + linear_extrude(height = inner_front_edge_width) + polygon([ + [-extra, -inner_front_edge_depth], + [0, -inner_front_edge_depth], + [inner_front_edge_height, 0], + [-extra, 0], + ]); - translate([inner_front_edge_width / 2, -int_front_depth, -height / 2]) - rotate([0, -90, 0]) - linear_extrude(height = inner_front_edge_width) - polygon([ - [-extra, -inner_front_edge_depth], - [0, -inner_front_edge_depth], - [inner_front_edge_height, 0], - [-extra, 0], - ]); + /* Inner top cutout for the top and sides of the back portion. */ - /* Inner top cutout for the top and sides of the back portion. */ + cube_at(inner_top_front_cutout_width, + inner_top_front_cutout_depth, + inner_top_front_cutout_height, + 0, -1, 1, + 0, 0, int_payload_upper_extent); - cube_at(inner_top_front_cutout_width, - inner_top_front_cutout_depth, - inner_top_front_cutout_height, - 0, -1, 1, - 0, 0, int_payload_upper_extent); + cube_at(inner_side_front_cutout_width, + inner_side_front_cutout_depth, + inner_side_front_cutout_height, + 1, -1, 0, + int_width / 2, 0, -inner_top_front_cutout_height); - cube_at(inner_side_front_cutout_width, - inner_side_front_cutout_depth, - inner_side_front_cutout_height, - 1, -1, 0, - int_width / 2, 0, -inner_top_front_cutout_height); + cube_at(inner_side_front_cutout_width, + inner_side_front_cutout_depth, + inner_side_front_cutout_height, + -1, -1, 0, + -int_width / 2, 0, -inner_top_front_cutout_height); - cube_at(inner_side_front_cutout_width, - inner_side_front_cutout_depth, - inner_side_front_cutout_height, - -1, -1, 0, - -int_width / 2, 0, -inner_top_front_cutout_height); + /* Fillets to round off the edges. */ + + union() { - /* Fillets to round off the edges. */ - - union() { - - /* Top left and right rounding. */ - - translate([-width / 2 + ro, -front_depth / 2, height / 2 - ro]) - rotate([0, 0, 180]) + /* Top left and right rounding. */ + + translate([-width / 2 + ro, -front_depth / 2, height / 2 - ro]) + rotate([0, 0, 180]) + rotate([90, 0, 0]) + fillet(rr, front_depth); + translate([width / 2 - ro, -front_depth / 2, height / 2 - ro]) rotate([90, 0, 0]) fillet(rr, front_depth); - translate([width / 2 - ro, -front_depth / 2, height / 2 - ro]) - rotate([90, 0, 0]) - fillet(rr, front_depth); - /* Top front rounding. */ - - translate([0, -front_depth + ro, height / 2 - ro]) - rotate([0, 0, 180]) - rotate([0, -90, 0]) - fillet(rr, width); + /* Top front rounding. */ + + translate([0, -front_depth + ro, height / 2 - ro]) + rotate([0, 0, 180]) + rotate([0, -90, 0]) + fillet(rr, width); - /* Edge rounding. */ - - translate([-width / 2 + ro, -front_depth + ro, 0]) - rotate([0, 0, 180]) - fillet(rr, height); - translate([width / 2 - ro, -front_depth + ro, 0]) - rotate([0, 0, 270]) - fillet(rr, height); + /* Edge rounding. */ + + translate([-width / 2 + ro, -front_depth + ro, 0]) + rotate([0, 0, 180]) + fillet(rr, height); + translate([width / 2 - ro, -front_depth + ro, 0]) + rotate([0, 0, 270]) + fillet(rr, height); + } } - } /* Place the back piece next to the front, with the internals facing out - the same way. + the same way, if APART is defined. */ - translate([width * 0.6, 0, 0]) - rotate([0, 0, 180]) - difference() { + back_displacement = APART ? width * 0.6 : 0; + back_rotation = APART ? 180 : 0; + + if (BACK) + translate([back_displacement, 0, 0]) + rotate([0, 0, back_rotation]) + difference() { + + /* The cartridge surfaces. */ + + union() { + + /* Back portion. */ - /* The cartridge surfaces. */ + if (BACK_SURFACE) { + cube_at(width, back, height, + 0, 1, 0, + 0, int_back_depth, 0); + cube_at(back_left, back_depth + groove_width_extra, height, + -1, 1, 0, + -int_width / 2, -groove_width_extra, 0); + cube_at(back_right, back_depth + groove_width_extra, height, + 1, 1, 0, + int_width / 2, -groove_width_extra, 0); + cube_at(width, back_depth + groove_width_extra, top, + 0, 1, 1, + 0, -groove_width_extra, int_payload_upper_extent); + } - union() { + difference() { - /* Back portion. */ + /* Floor of cartridge. */ - cube_at(width, back, height, - 0, 1, 0, - 0, int_back_depth, 0); - cube_at(back_left, back_depth + groove_width_extra, height, - -1, 1, 0, - -int_width / 2, -groove_width_extra, 0); - cube_at(back_right, back_depth + groove_width_extra, height, - 1, 1, 0, - int_width / 2, -groove_width_extra, 0); - cube_at(width, back_depth + groove_width_extra, top, - 0, 1, 1, - 0, -groove_width_extra, int_payload_upper_extent); + cube_at(width, back_depth, bottom, + 0, 1, 1, + 0, 0, -height / 2 + int_connector_height); + + /* Edge connector cutout. */ + + cube_at(edge_connector_cutout_back_width, + edge_connector_cutout_back_depth, + bottom, + 0, 1, 1, + 0, 0, -height / 2 + int_connector_height); + } + + /* PCB supports. */ - difference() { - - /* Floor of cartridge. */ + pcb_support(-1, pcb_back_support_left_bump_height, + pcb_back_support_left_bump_offset_from_bottom); + pcb_support(1, pcb_back_support_right_bump_height, + pcb_back_support_right_bump_offset_from_bottom); - cube_at(width, back_depth, bottom, - 0, 1, 1, - 0, 0, -height / 2 + int_connector_height); + /* Circular "lugs" to hold PCBs in place. */ + + pcb_lug(-1); + pcb_lug(1); + } - /* Edge connector cutout. */ + /* Label insets. */ + + union() { + + /* Top label. See also the front piece. */ - cube_at(edge_connector_cutout_back_width, - edge_connector_cutout_back_depth, - bottom, - 0, 1, 1, - 0, 0, -height / 2 + int_connector_height); + if (TOP_LABEL_INSET) + translate([-top_label_width / 2, + -front_depth + top_label_offset_from_front, + height / 2 - top_label_depth]) + cube([top_label_width, top_label_height, + top_label_depth]); } - /* PCB supports. */ - - pcb_support(-1, pcb_back_support_left_bump_height, - pcb_back_support_left_bump_offset_from_bottom); - pcb_support(1, pcb_back_support_right_bump_height, - pcb_back_support_right_bump_offset_from_bottom); - - /* Circular "lugs" to hold PCBs in place. */ + /* Top and side grooves, positioned in the back portion. */ - pcb_lug(-1); - pcb_lug(1); - } + union() { - /* Label insets. */ - - union() { - - /* Top label. See also the front piece. */ + /* Left groove. */ - if (TOP_LABEL_INSET) - translate([-top_label_width / 2, - -front_depth + top_label_offset_from_front, - height / 2 - top_label_depth]) - cube([top_label_width, top_label_height, - top_label_depth]); - } - - /* Top and side grooves, positioned in the back portion. */ - - union() { + cube_at(groove_depth, groove_width, height, + 1, 1, 0, + -width / 2, -groove_width_extra, 0); - /* Left groove. */ - - cube_at(groove_depth, groove_width, height, - 1, 1, 0, - -width / 2, -groove_width_extra, 0); - - /* Right groove. */ - - cube_at(groove_depth, groove_width, height, - -1, 1, 0, - width / 2, -groove_width_extra, 0); + /* Right groove. */ - /* Top grooves. */ - - cube_at(width, groove_width, groove_depth, - 0, 1, -1, - 0, -groove_width_extra, height / 2); + cube_at(groove_depth, groove_width, height, + -1, 1, 0, + width / 2, -groove_width_extra, 0); - cube_at(width, top_groove_width, top_groove_depth, - 0, 1, -1, - 0, -groove_width_extra, height / 2); - } - - /* Back cavity. */ - - if (BACK_CAVITY) - intersection() { - - /* From the bottom upwards. */ + /* Top grooves. */ - translate([0, back_depth, -height / 2]) - linear_extrude(height = back_cavity_height) - translate([-int_width / 2, 0, 0]) - polygon([ - [back_cavity_offset_from_inner_left, 0], - [back_cavity_inner_offset_from_inner_left, - -back_cavity_depth], - [back_cavity_inner_offset_from_inner_left + - back_cavity_inner_width, - -back_cavity_depth], - [back_cavity_offset_from_inner_left + - back_cavity_width, 0] - ]); + cube_at(width, groove_width, groove_depth, + 0, 1, -1, + 0, -groove_width_extra, height / 2); - /* From left to right. */ - - translate([back_cavity_width / 2, back_depth, -height / 2]) - rotate([0, -90, 0]) - linear_extrude(height = back_cavity_width) - polygon([ - [-extra, -back_cavity_depth], - [back_cavity_inner_height, - -back_cavity_depth], - [back_cavity_height, 0], - [-extra, 0] - ]); + cube_at(width, top_groove_width, top_groove_depth, + 0, 1, -1, + 0, -groove_width_extra, height / 2); } - /* Inner back cavities. */ + /* Back cavity. */ + + if (BACK_CAVITY) + intersection() { + + /* From the bottom upwards. */ - translate([0, int_back_depth, -height / 2]) - linear_extrude(height = int_connector_height) - translate([-int_width / 2, 0, 0]) - polygon([ - [0, 0], - [inner_back_slope_max_offset, 0], - [inner_back_slope_min_offset, - inner_back_slope_depth], - [0, inner_back_slope_depth] - ]); + translate([0, back_depth, -height / 2]) + linear_extrude(height = back_cavity_height) + translate([-int_width / 2, 0, 0]) + polygon([ + [back_cavity_offset_from_inner_left, 0], + [back_cavity_inner_offset_from_inner_left, + -back_cavity_depth], + [back_cavity_inner_offset_from_inner_left + + back_cavity_inner_width, + -back_cavity_depth], + [back_cavity_offset_from_inner_left + + back_cavity_width, 0] + ]); + + /* From left to right. */ + + translate([back_cavity_width / 2, back_depth, -height / 2]) + rotate([0, -90, 0]) + linear_extrude(height = back_cavity_width) + polygon([ + [-extra, -back_cavity_depth], + [back_cavity_inner_height, + -back_cavity_depth], + [back_cavity_height, 0], + [-extra, 0] + ]); + } + + /* Inner back cavities. */ - translate([0, int_back_depth, -height / 2]) - linear_extrude(height = int_connector_height) - translate([int_width / 2, 0, 0]) - polygon([ - [0, 0], - [-inner_back_slope_max_offset, 0], - [-inner_back_slope_min_offset, - inner_back_slope_depth], - [0, inner_back_slope_depth] - ]); + translate([0, int_back_depth, -height / 2]) + linear_extrude(height = int_connector_height) + translate([-int_width / 2, 0, 0]) + polygon([ + [0, 0], + [inner_back_slope_max_offset, 0], + [inner_back_slope_min_offset, + inner_back_slope_depth], + [0, inner_back_slope_depth] + ]); - /* Inner back edge cavity. */ + translate([0, int_back_depth, -height / 2]) + linear_extrude(height = int_connector_height) + translate([int_width / 2, 0, 0]) + polygon([ + [0, 0], + [-inner_back_slope_max_offset, 0], + [-inner_back_slope_min_offset, + inner_back_slope_depth], + [0, inner_back_slope_depth] + ]); - translate([inner_back_edge_width / 2, - int_back_depth + inner_back_edge_depth, -height / 2]) - rotate([0, -90, 0]) - linear_extrude(height = inner_back_edge_width) - polygon([ - [-extra, -inner_back_edge_depth], - [inner_back_edge_height, -inner_back_edge_depth], - [0, 0], - [-extra, 0] - ]); + /* Inner back edge cavity. */ - /* Fillets to round off the edges. */ - - union() { + translate([inner_back_edge_width / 2, + int_back_depth + inner_back_edge_depth, -height / 2]) + rotate([0, -90, 0]) + linear_extrude(height = inner_back_edge_width) + polygon([ + [-extra, -inner_back_edge_depth], + [inner_back_edge_height, -inner_back_edge_depth], + [0, 0], + [-extra, 0] + ]); - /* Top left and right rounding. */ - - translate([-width / 2 + ro, back_depth / 2, height / 2 - ro]) - rotate([0, 0, 180]) + /* Fillets to round off the edges. */ + + union() { + + /* Top left and right rounding. */ + + translate([-width / 2 + ro, back_depth / 2, height / 2 - ro]) + rotate([0, 0, 180]) + rotate([90, 0, 0]) + fillet(rr, back_depth); + translate([width / 2 - ro, back_depth / 2, height / 2 - ro]) rotate([90, 0, 0]) fillet(rr, back_depth); - translate([width / 2 - ro, back_depth / 2, height / 2 - ro]) - rotate([90, 0, 0]) - fillet(rr, back_depth); - - /* Top back rounding. */ - - translate([0, back_depth - ro, height / 2 - ro]) - rotate([0, -90, 0]) - fillet(rr, width); - - /* Edge rounding. */ - - translate([width / 2 - ro, back_depth - ro, 0]) - fillet(rr, height); - translate([-width / 2 + ro, back_depth - ro, 0]) - rotate([0, 0, 90]) + + /* Top back rounding. */ + + translate([0, back_depth - ro, height / 2 - ro]) + rotate([0, -90, 0]) + fillet(rr, width); + + /* Edge rounding. */ + + translate([width / 2 - ro, back_depth - ro, 0]) fillet(rr, height); + translate([-width / 2 + ro, back_depth - ro, 0]) + rotate([0, 0, 90]) + fillet(rr, height); + } } - } } cartridge();