Date de création 2020-12-02Date d’expiration 2021-03-05/* "Small box" is a Customizer compatible script that allows you to create small boxes given the dimensions of the object it should contain. Created by Frédéric Bisson <zigazou@protonmail.com> Public domain. */ // Part to print part = "container"; // [container,cover,test] /* [Box inner size] */ // Inner width in mm inner_width = 88; // [10:0.1:200] // Inner height in mm inner_height = 58; // [10:0.1:200] // Inner depth in mm inner_depth = 25; // [10:0.1:200] /* [Subdivision] */ // Width subdivision horz_count = 1; // [1:10] // Height subdivision vert_count = 1; // [1:10] /* [Advanced settings] */ // Thickness in mm thickness = 3; // [1:0.05:5] // Gutter in mm gutter = 1.5; // [1:0.05:5] // Subdivision wall thickness in mm wall_thickness = 1; // [1:0.05:5] /* [Hidden] */ // Value used to avoid inexisting surface to appear in preview mode iota = 1; // Value used to allow embedding of pieces after printing backlash = 0.5; module container() { difference() { // Main box cube([ thickness + inner_width + thickness, thickness + inner_height + thickness, thickness + inner_depth + gutter + thickness ]); // Content translate([thickness, thickness, thickness]) cube([ inner_width, inner_height, inner_depth + gutter + thickness + iota ]); // Cover rail translate([-iota, gutter, thickness + inner_depth]) cube([ iota + thickness + inner_width + gutter, gutter + inner_height + gutter, gutter ]); translate([-iota, thickness, thickness + inner_depth]) cube([ iota + thickness + iota, inner_height, gutter + thickness + iota ]); } // Width subdivision if (horz_count > 1) { for (i = [1:horz_count - 1]) { translate([ thickness + i * inner_width / horz_count - wall_thickness / 2, 0, 0 ]) cube([ wall_thickness, thickness + inner_height + thickness, inner_depth + thickness ]); } } // Height subdivision if (vert_count > 1) { for (i = [1:vert_count - 1]) { translate([ 0, thickness + i * inner_height / vert_count - wall_thickness / 2, 0 ]) cube([ thickness + inner_width + thickness, wall_thickness, inner_depth + thickness ]); } } } module cover() { base_height = gutter - backlash + inner_height + gutter - backlash; nail_diameter = 30; nail_angle = 80; nail_height = 100; difference() { union() { // Base cube([ thickness + inner_width + gutter - backlash, base_height, gutter - backlash ]); // Upper part translate([0, gutter, 0]) cube([ thickness + inner_width - backlash, - backlash + inner_height - backlash, gutter + thickness ]); } // Nail translate([thickness, base_height / 2, gutter]) difference() { rotate([0, nail_angle, 0]) translate([-nail_diameter / 2, 0, 0]) cylinder(d=nail_diameter, h=nail_height, $fn=100); translate([-nail_diameter, -nail_diameter / 2, 0]) cube([nail_diameter, nail_diameter, nail_diameter]); } } } module print_part() { if (part == "cover") { cover(); } else if (part == "container") { container(); } else { #container(); color("blue") translate([ 0, thickness - gutter + backlash, thickness + inner_depth ]) cover(); } } print_part();