OpenSCAD improvements
This commit is contained in:
@@ -2,11 +2,19 @@
|
||||
include <BOSL2/std.scad>
|
||||
include <BOSL2/skin.scad>
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user