92 lines
2.4 KiB
OpenSCAD
92 lines
2.4 KiB
OpenSCAD
// For “custom”, you must also set the “dimensions” parameter.
|
|
shape = "flat"; // [unit,rod,flat,cube,custom]
|
|
|
|
groove_depth = 0.8; // [0:0.1:3]
|
|
|
|
unit_size = 10; // [0:0.1:40]
|
|
|
|
/* [Custom dimensions] */
|
|
|
|
dimensions = [2,3,4];
|
|
|
|
module __Customizer_Limit__ () {}
|
|
|
|
actual_dimensions = shape == "cube" ? [10,10,10] :
|
|
shape == "flat" ? [10,10,1] :
|
|
shape == "rod" ? [10,1,1] :
|
|
shape == "unit" ? [1,1,1] : dimensions;
|
|
|
|
module cube_block(x_count, y_count, z_count, cube_width=10, groove_depth=0.8) {
|
|
|
|
module corner_chamfer() {
|
|
linear_extrude(2*groove_depth*sqrt(2))
|
|
polygon([
|
|
[-groove_depth*sqrt(2),-groove_depth],
|
|
[0,0],
|
|
[groove_depth*sqrt(2),-groove_depth]]);
|
|
}
|
|
|
|
module grooves(length, count) {
|
|
for (x = [0:cube_width:count*cube_width]) {
|
|
translate([x,0,0]) {
|
|
// Make sure the edges overlap with the cube.
|
|
extra_depth = groove_depth*0.01;
|
|
extra_length = length*0.01;
|
|
translate([0,0,-extra_length/2])
|
|
linear_extrude(length+extra_length)
|
|
polygon([
|
|
[-groove_depth-extra_depth,-extra_depth],
|
|
[0,groove_depth],
|
|
[groove_depth+extra_depth,-extra_depth]]);
|
|
|
|
translate([0,2*groove_depth,0])
|
|
rotate([45,0,0])
|
|
corner_chamfer();
|
|
translate([0,2*groove_depth,length])
|
|
mirror([0,0,1])
|
|
rotate([45,0,0])
|
|
corner_chamfer();
|
|
}
|
|
}
|
|
}
|
|
|
|
x_width = x_count * cube_width;
|
|
y_width = y_count * cube_width;
|
|
z_width = z_count * cube_width;
|
|
|
|
difference() {
|
|
cube([x_width,y_width,z_width]);
|
|
|
|
grooves(z_width, x_count);
|
|
translate([0,y_width,0])
|
|
mirror([0,1,0]) grooves(z_width, x_count);
|
|
|
|
mirror([0,-1,1]) {
|
|
grooves(y_width, x_count);
|
|
translate([0,z_width,0])
|
|
mirror([0,1,0]) grooves(y_width, x_count);
|
|
}
|
|
mirror([1,-1,0]) {
|
|
grooves(z_width, y_count);
|
|
translate([0,x_width,0])
|
|
mirror([0,1,0]) grooves(z_width, y_count);
|
|
}
|
|
mirror([-1,0,1]) mirror([1,-1,0]) {
|
|
grooves(x_width, y_count);
|
|
translate([0,z_width,0])
|
|
mirror([0,1,0]) grooves(x_width, y_count);
|
|
}
|
|
mirror([-1,0,1]) {
|
|
grooves(x_width, z_count);
|
|
translate([0,y_width,0])
|
|
mirror([0,1,0]) grooves(x_width, z_count);
|
|
}
|
|
mirror([1,-1,0]) mirror([-1,0,1]) {
|
|
grooves(y_width, z_count);
|
|
translate([0,x_width,0])
|
|
mirror([0,1,0]) grooves(y_width, z_count);
|
|
}
|
|
}
|
|
};
|
|
|
|
cube_block(actual_dimensions.x, actual_dimensions.y, actual_dimensions.z, cube_width=unit_size, groove_depth=groove_depth); |