| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- include <../config/splited.scad>
- module splited_object() {
- width = splited_width;
- height = splited_height;
- depth = splited_depth;
- thickness = splited_thickness;
- hole_top_diameter = splited_hole_top_diameter;
- hole_bottom_diameter = splited_hole_bottom_diameter;
- holes_top_count = splited_holes_top_count;
- holes_bottom_count = splited_holes_bottom_count;
- module splited_cross_section(full = true) {
- module points(top = false) {
- radius = thickness / 2;
- move_x = depth / 2 - radius;
- move_y = height / 2 - radius;
- module point(x = 0, y = 0) {
- translate([x, y]) {
- circle(r = radius);
- }
- }
-
- hull() {
- if (top) {
- point(move_x, move_y);
- point(-move_x, move_y);
- } else {
- point(-move_x, -move_y);
- point(-move_x, move_y);
- }
- }
- }
-
- if (full) {
- hull() {
- points(top = true);
- points(top = false);
- }
- } else {
- points(top = true);
- points(top = false);
- }
- }
- module center_section() {
- linear_extrude(height = thickness, center = true) {
- splited_cross_section(full = true);
- }
- }
- module rest_section() {
- linear_extrude(height = width, center = true) {
- splited_cross_section(full = false);
- }
- }
- module holes(size, height, count, top = false) {
- move = size / count;
- for (count = [-size / 2 : move : size / 2 - move / 2]) {
- translate([count + move / 2, 0]) {
- linear_extrude(height = height, center = true) {
- if (top) {
- circle(d = hole_top_diameter);
- } else {
- circle(d = hole_bottom_diameter);
- }
- }
- }
- }
- }
- module holes_height() {
- module single() {
- rotate([90, 0, 90]) {
- holes(
- size = height - thickness * 2,
- height = depth,
- count = holes_bottom_count,
- top = false
- );
- }
- }
- move = (width + thickness) / 4;
- translate([0, 0, move]) {
- single();
- }
- translate([0, 0, -move]) {
- single();
- }
- }
- module holes_depth() {
- module single() {
- rotate([90, 0, 0]) {
- holes(
- size = depth - thickness * 2,
- height = depth,
- count = holes_top_count,
- top = true
- );
- }
- }
- move = (width + thickness) / 4;
- translate([0, 0, move]) {
- single();
- }
- translate([0, 0, -move]) {
- single();
- }
- }
- module final() {
- render() {
- difference() {
- union() {
- center_section();
- rest_section();
- }
- holes_height();
- holes_depth();
- }
- }
- }
- color("#404040") {
- final();
- }
- }
|