From 9bd1b7ac5c161b2f2a9da3c95581eab2775165f4 Mon Sep 17 00:00:00 2001 From: Stefan Thoss Date: Mon, 6 Jan 2025 20:48:47 -0800 Subject: [PATCH] OpenSCAD improvements --- .../exhaust-vent-wall-plate.scad | 2 +- .../simple-rounded-s-hook.scad | 63 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/exhaust-vent-wall-plate/exhaust-vent-wall-plate.scad b/exhaust-vent-wall-plate/exhaust-vent-wall-plate.scad index 450c79d..483f3a3 100644 --- a/exhaust-vent-wall-plate/exhaust-vent-wall-plate.scad +++ b/exhaust-vent-wall-plate/exhaust-vent-wall-plate.scad @@ -6,7 +6,7 @@ plate_rounding = 20; wall_thickness = 2; -hex_hole_size = 4; +hex_hole_size = 4; // [4:0.5:20] hex_spacing = hex_hole_size/2; pipe_outer_diameter = 100; diff --git a/simple-rounded-s-hook/simple-rounded-s-hook.scad b/simple-rounded-s-hook/simple-rounded-s-hook.scad index 413d833..b57dc04 100644 --- a/simple-rounded-s-hook/simple-rounded-s-hook.scad +++ b/simple-rounded-s-hook/simple-rounded-s-hook.scad @@ -2,11 +2,19 @@ include include -loop_r = 30; -hook_d = 15; -hook_angle = 145; -straight_l = 85; -flatten_h = hook_d/20; +// Radius of the hook ends +loop_radius = 30; + +// Diameter of the hook +hook_diameter = 15; + +// How many degrees should the hook ends bend +hook_angle = 145; // [60:270] + +// Length of the straight part +straight_length = 85; + +flatten_height = hook_diameter/20; $fn=80; @@ -14,44 +22,35 @@ difference() { /* Hook */ group() { /* Start cap */ - rotate([0,-90,0]) { - rotate_extrude(){ + rotate([0,-90,0]) + rotate_extrude() intersection(){ - circle(d=hook_d); - square(hook_d); + circle(d=hook_diameter); + square(hook_diameter); } - } - } /* Draw the hook */ - turtle_cmds = ["arcrightto", loop_r, hook_angle, - "move", straight_l, - "arcleftto", loop_r, 0]; - path = turtle(turtle_cmds, - state=[0,0], - full_state=false); - path_sweep(circle(d = hook_d), path); + turtle_cmds = ["arcrightto", loop_radius, hook_angle, + "move", straight_length, + "arcleftto", loop_radius, 0]; + path = turtle(turtle_cmds, state=[0,0], full_state=false); + path_sweep(circle(d = hook_diameter), path); /* End cap */ - translate(path[len(path) - 1]) { - rotate([0,90,0]) { - rotate_extrude(){ + translate(path[len(path) - 1]) + rotate([0,90,0]) + rotate_extrude() intersection(){ - circle(d=hook_d); - square(hook_d); + circle(d=hook_diameter); + square(hook_diameter); } - } - } - } } /* Flatten the hook with two cubes */ group(){ - translate([-4*straight_l+2*loop_r,-2*straight_l+loop_r,(hook_d/2)-flatten_h]) { - cube([4*straight_l,2*straight_l,flatten_h]); - } - translate([-4*straight_l+2*loop_r,-2*straight_l+loop_r,-(hook_d/2)]) { - cube([4*straight_l,2*straight_l,flatten_h]); - } + translate([-4*straight_length+2*loop_radius,-2*straight_length+loop_radius,(hook_diameter/2)-flatten_height]) + cube([4*straight_length,2*straight_length,flatten_height]); + translate([-4*straight_length+2*loop_radius,-2*straight_length+loop_radius,-(hook_diameter/2)]) + cube([4*straight_length,2*straight_length,flatten_height]); } } \ No newline at end of file