Rework band as path sweep

This commit is contained in:
2025-02-09 23:51:08 -08:00
parent 9a32816461
commit 53c32b3f52

173
band.scad
View File

@@ -2,99 +2,120 @@ include <BOSL2/std.scad>;
$fn = $preview ? 32 : 128; $fn = $preview ? 32 : 128;
band_arc_radius = 65; band_arc_radius = 75;
thickness = 3; band_thickness = 3;
height = 10; band_height = 10;
band_arc = 240;
leg_length = 27; leg_length = 27;
edge_radius = 0.5; edge_radius = 0.5;
punch_angles = [-95, -70, -45, 0, 45, 70, 95];
tooth_width=2;
tooth_height=2.5;
teeth_max_angle = 110;
teeth_spacing = 2.5;
punch_clearance = 5;
module tooth() { band_arc = turtle([
"move", leg_length,
"arcright", band_arc_radius, 80,
"arcright", band_arc_radius * 0.8, 20,
"arcright", band_arc_radius * 1.2, 40,
"arcright", band_arc_radius * 0.8, 20,
"arcright", band_arc_radius, 80,
"move", leg_length
]);
band_profile = rect(
size=[band_thickness, band_height],
rounding=edge_radius
);
band_length = path_length(band_arc);
band_curve_length = band_length-leg_length*2;
leg_frac = leg_length/band_length;
band_curve_frac = 1-leg_frac*2;
tooth_width = 2;
tooth_height = 2.5;
tooth_offset = band_height/2-2;
dense_teeth_count = 70;
teeth_step = band_curve_frac/dense_teeth_count;
punch_fracs = [
for(frac=[0.07, 0.18, 0.29, 0.5, 0.71, 0.82, 0.93])
frac * band_curve_frac + leg_frac
];
function hole(anchor) = rect(
size=[band_height/2+1, band_height/2],
rounding=band_height/4,
anchor=anchor
);
module punch() linear_sweep(
region=[
right(1, p=hole(LEFT)),
left(1, p=hole(RIGHT))
],
length=band_thickness+2
);
function punch_clearance(tooth_frac, punch_frac) = abs(punch_frac - tooth_frac) > 0.025;
module punches()
for(punch_frac=punch_fracs)
sweep_attach(
parent=LEFT,
child=BOT,
frac=punch_frac,
spin=90,
overlap=band_thickness+1
)
tag("remove")
punch();
module tooth()
cyl( cyl(
d1=tooth_width, d1=tooth_width,
d2=edge_radius*2, d2=edge_radius*2,
h=tooth_height, h=tooth_height,
rounding2=edge_radius, rounding2=edge_radius
anchor=BOT,
orient=FWD
); );
}
module punch() { module teeth()
region = right( for(tooth_frac=[leg_frac:teeth_step:1-leg_frac])
1, if(
p=rect( all([
[height/2+1, height/2], for (punch_frac=punch_fracs)
rounding=height/4, punch_clearance(tooth_frac, punch_frac)
anchor=LEFT ])
) )
); sweep_attach(LEFT, BOT, tooth_frac) {
linear_sweep( left(tooth_offset) tooth();
[region, xflip(region)], right(tooth_offset) tooth();
length=thickness+2, }
center=true,
orient=BACK
);
}
pip_count = 4;
pip_size = 1.2;
pip_frac_step = 0.0045;
module band() { module pips()
region = right( for(pip_idx=[0:1:pip_count-1])
band_arc_radius, sweep_attach(
p=rect( parent=LEFT,
[thickness, height], child=BOT,
rounding=edge_radius frac=leg_frac+pip_idx*pip_frac_step,
overlap=pip_size/2
) )
); tag("remove")
rotate_sweep( sphere(d=pip_size);
region,
angle=band_arc,
spin=-band_arc/2+90
);
}
module leg() { module ends()
rotate(-band_arc/2+90) attach(["end", "start"])
right(band_arc_radius)
cuboid(
[thickness, leg_length, height],
rounding=edge_radius,
edges="Y",
anchor=BACK
)
attach(FWD)
xcyl( xcyl(
thickness, h=band_thickness,
d=height, d=band_height,
rounding=edge_radius rounding=edge_radius
); );
}
difference() { module band()
union() { diff()
band(); path_sweep(band_profile, band_arc) {
leg(); punches();
xflip() leg(); teeth();
pips();
ends();
} }
for(a=punch_angles) {
zrot(a) back(band_arc_radius) punch();
}
}
for(a=[-teeth_max_angle:teeth_spacing:teeth_max_angle]) { band();
if(all([
for (b=punch_angles)
abs(b - a) > punch_clearance
])) {
zrot(a) back(band_arc_radius-thickness/2+0.1) {
up(height/4) tooth();
down(height/4) tooth();
};
}
}