Code cleaning + add ears to the bottle clip! #22

Open
ajabep wants to merge 23 commits from ajabep/scad:trunk into trunk
Showing only changes of commit 6364985e55 - Show all commits

Add a function to generate a the bottle clip depending on the asked format

Ajabep 2026-01-11 10:03:00 +01:00

View file

@ -77,84 +77,55 @@ $fn = 360;
* using meshlab to run `Filters` -> `Cleaning and Repairing` -> `Remove T-Vertices` by `Edge-Flip` with `Ratio` of `1000000` before importing the stl works but but two errors remain.
*/
scale([0.2, 0.2, 0.2]) {
difference() {
scale([5, 5, 5])
rotate(45, [0, 0, 1])
bottle_clip_format(
name=NAME,
font=FONT,
logo=LOGO_FILE,
format=FORMAT);
translate([ 15*5, 0*5, 18*5])
rotate(-80, [0, 1, 0])
catear();
translate([-15*5, 0*5, 18*5])
rotate(-80, [0, 1, 0])
catear();
}
if (RENDER_COLOR_TEXT) {
color("orange")
translate([ 15*5, 0*5, 18*5])
rotate(80, [0, 1, 0])
catear();
}
if (RENDER_COLOR_LOGO) {
color("yellow")
translate([-15*5, 0*5, 18*5])
rotate(-80, [0, 1, 0])
catear();
}
render_bottle_clip(
name=NAME,
font=FONT,
logo=LOGO_FILE,
format=FORMAT,
has_ears=USE_TINY_EARS);
}
module bottle_clip_format(name="", font="", logo="", format=0) {
module render_bottle_clip(name="", font="", logo="", format=0, has_ears=true) {
name = name == "" ? "c3cat" : name ;
font = font == "" ? "write/orbitron.dxf" : font ;
if (format == 0) {
// Club-Mate 0.5L bottle
bottle_clip(
name=name,
font=font,
logo=logo,
ru=13,
rl=17.5,
ht=26,
width=2.5);
} else if (format == 1) {
// 0.25L Long Neck format (like fritz-kola)
bottle_clip(
name=name,
font=font,
logo=logo,
ru=13,
rl=15,
ht=26,
width=2.5);
} else if (format == 2) {
// Euroform 2 bottle
bottle_clip(
name=name,
font=font,
logo=logo,
ru=13,
rl=22.5,
ht=26,
width=2.5);
} else if (format == 3) {
// Steinie bottle
bottle_clip(
name=name,
font=font,
logo=logo,
ru=13,
rl=17.5,
ht=13,
width=2.5);
} else {
if (format < 0 || format > 3) {
assert(false, str("Unknown format ", format, "."));
}
// Format == 0: Club-Mate 0.5L bottle
// Format == 1: Long Neck bottle (like fritz-kola) 0.25L
// Format == 2: Euroform 2 bottle
// Format == 3: Steinie bottle
ru = 13;
rl = format == 1 ? 15 : format == 2 ? 22.5 : 17.5 ;
ht = format == 3 ? 13 : 26 ;
width = 2.5;
scale([5, 5, 5])
rotate(45, [0, 0, 1]) {
difference() {
bottle_clip(
name=NAME,
font=FONT,
logo=LOGO_FILE,
ru=ru,
rl=rl,
ht=ht,
width=width);
// Render ears if requested
if (has_ears) {
ears(ht=ht, ru=ru, rl=rl);
}
}
// Render ears if requested
if (has_ears) {
ears(ht=ht, ru=ru, rl=rl);
}
}
}
module name(name, font, rl, ht, ru) {
@ -171,6 +142,7 @@ module name(name, font, rl, ht, ru) {
module logo(logo, rl, ht, ru, width) {
echo(logo=logo);
if(logo == "") {
// No logo file specified? Let's print a catear headband instead!
ear_size=ht;
echo(ht=ht);
echo(ru=ru);
@ -274,7 +246,7 @@ module outer_cutoff(rl, e, ru, ht, width) {
}
}
module catear() {
module ear() {
if (USE_TINY_EARS) {
rotate(-90, [0, 0, 1]) union() {
scale([1, 1 ,1]) translate([0, -85]) import("catear.stl");