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 2ac86c04a9 - Show all commits

Fix rotation problem

Ajabep 2026-01-14 17:29:00 +01:00

View file

@ -105,29 +105,28 @@ module render_bottle_clip(name="", font="", logo="", format=0, has_ears=true) {
width = 2.5; width = 2.5;
scale([5, 5, 5]) scale([5, 5, 5]) {
rotate(45, [0, 0, 1]) { difference() {
difference() { bottle_clip(
bottle_clip( name=NAME,
name=NAME, font=FONT,
font=FONT, logo=LOGO_FILE,
logo=LOGO_FILE, ru=ru,
ru=ru, rl=rl,
rl=rl, ht=ht,
ht=ht, width=width);
width=width);
// Render ears if requested
if (has_ears) {
ears(ht=ht, ru=ru, rl=rl);
}
}
// Render ears if requested // Render ears if requested
if (has_ears && RENDER_COLOR_EARS) { if (has_ears) {
ears(ht=ht, ru=ru, rl=rl); ears(ht=ht, ru=ru, rl=rl, clip_width=width, ears_style=ears_style);
} }
} }
// Render ears if requested
if (has_ears && RENDER_COLOR_EARS) {
ears(ht=ht, ru=ru, rl=rl, clip_width=width, ears_style=ears_style);
}
}
} }
module name(name, font, rl, ht, ru) { module name(name, font, rl, ht, ru) {
@ -197,43 +196,42 @@ module logo(logo, rl, ht, ru, width) {
module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="c3cat", font="write/orbitron.dxf", logo="") { module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="c3cat", font="write/orbitron.dxf", logo="") {
e = 100; // should be big enough, used for the outer boundary of the text/logo e = 100; // should be big enough, used for the outer boundary of the text/logo
rotate([0, 0, -45]) {
// main cylinder
if (RENDER_COLOR_CLIP) {
color("black") difference() {
cylinder(r1=rl+width, r2=ru+width, h=ht);
difference() {
union() {
name(name=name, font=font, rl=rl, ht=ht, ru=ru);
logo(logo=logo, rl=rl, ht=ht, ru=ru, width=width);
}
cylinder(r1=rl+width/2, r2=ru+width/2, h=ht);
}
clear_anti_aliasing = 0.01; // The margin to avoid empty surfaces in the preview. // main cylinder
translate([0, 0, -clear_anti_aliasing/2]) if (RENDER_COLOR_CLIP) {
cylinder(r1=rl, r2=ru, h=ht+clear_anti_aliasing); color("black") difference() {
// finally, subtract a cube as a gap so we can clip it to the bottle cylinder(r1=rl+width, r2=ru+width, h=ht);
rotate([0, 0, 45]) difference() {
translate([0, 0, -1]) union() {
cube([50, 50, 50]); name(name=name, font=font, rl=rl, ht=ht, ru=ru);
} logo(logo=logo, rl=rl, ht=ht, ru=ru, width=width);
} }
// text
if (RENDER_COLOR_TEXT) {
color("orange") difference() {
name(name=name, font=font, rl=rl, ht=ht, ru=ru);
cylinder(r1=rl+width/2, r2=ru+width/2, h=ht); cylinder(r1=rl+width/2, r2=ru+width/2, h=ht);
outer_cutoff(rl, e, ru, ht, width);
} }
clear_anti_aliasing = 0.01; // The margin to avoid empty surfaces in the preview.
translate([0, 0, -clear_anti_aliasing/2])
cylinder(r1=rl, r2=ru, h=ht+clear_anti_aliasing);
// finally, subtract a cube as a gap so we can clip it to the bottle
rotate([0, 0, 45])
translate([0, 0, -1])
cube([50, 50, 50]);
} }
// logo }
if (RENDER_COLOR_LOGO) { // text
color("yellow") difference() { if (RENDER_COLOR_TEXT) {
logo(logo=logo, rl=rl, ht=ht, ru=ru, width=2*width); color("orange") difference() {
cylinder(r1=rl+width/2, r2=ru+width/2, h=ht); name(name=name, font=font, rl=rl, ht=ht, ru=ru);
outer_cutoff(rl, e, ru, ht, width); cylinder(r1=rl+width/2, r2=ru+width/2, h=ht);
} outer_cutoff(rl, e, ru, ht, width);
}
}
// logo
if (RENDER_COLOR_LOGO) {
color("yellow") difference() {
logo(logo=logo, rl=rl, ht=ht, ru=ru, width=2*width);
cylinder(r1=rl+width/2, r2=ru+width/2, h=ht);
outer_cutoff(rl, e, ru, ht, width);
} }
} }
} }