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 b342b09dab - Show all commits

Fix indent, some typo, and all of that

Ajabep 2026-01-09 20:31:34 +01:00

View file

@ -33,8 +33,8 @@ $fn = 360;
NAME = "c3cat"; NAME = "c3cat";
LOGO_FILE = ""; // empty string is catear model LOGO_FILE = ""; // empty string is catear model
RENDER_COLOR_ONE = true; RENDER_COLOR_ONE = true;
RENDER_COLOR_TWO = true; RENDER_COLOR_TEXT = true;
RENDER_COLOR_THREE = true; RENDER_COLOR_LOGO = true;
USE_TINY_EARS = true; USE_TINY_EARS = true;
/** /**
@ -48,9 +48,9 @@ USE_TINY_EARS = true;
* rl: the radius on the lower side of the clip * rl: the radius on the lower side of the clip
* ht: the height of the clip * ht: the height of the clip
* width: the thickness of the wall. Values near 2.5 usually result in a good * width: the thickness of the wall. Values near 2.5 usually result in a good
* clippiness for PLA prints. * clippiness for PLA prints.
* name: the name that is printed on your name tag. For the default ru/rt/ht * name: the name that is printed on your name tag. For the default ru/rt/ht
* values, this string should not exceed 18 characters to fit on the name tag. * values, this string should not exceed 18 characters to fit on the name tag.
* font: the path to a font for Write.scad. * font: the path to a font for Write.scad.
*/ */
@ -61,9 +61,18 @@ USE_TINY_EARS = true;
*/ */
scale([0.2, 0.2, 0.2]) { scale([0.2, 0.2, 0.2]) {
difference() { difference() {
scale([5, 5, 5]) rotate(45, [0, 0, 1]) bottle_clip(name=NAME); scale([5, 5, 5])
translate([ 15*5, 0*5, 18*5]) rotate(80, [0, 1, 0]) catear(); rotate(45, [0, 0, 1])
translate([-15*5, 0*5, 18*5]) rotate(-80, [0, 1, 0]) catear(); bottle_clip(
name=NAME);
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_TWO) { if (RENDER_COLOR_TWO) {
color("orange") color("orange")
@ -82,7 +91,7 @@ scale([0.2, 0.2, 0.2]) {
module name(name, font, rl, ht, ru) { module name(name, font, rl, ht, ru) {
writecylinder( writecylinder(
text=name, text=name,
where=[0,0,0], where=[0, 0, 0],
radius=rl+0.5, radius=rl+0.5,
height=ht/13*7, height=ht/13*7,
h=ht/13*4, h=ht/13*4,
@ -91,22 +100,22 @@ module name(name, font, rl, ht, ru) {
} }
module logo(logo, rl, ht, ru, width) { module logo(logo, rl, ht, ru, width) {
echo("logo: ", logo); echo(logo=logo);
if(logo == "") { if(logo == "") {
ear_size=ht; ear_size=ht;
echo("ht: ", ht); echo(ht=ht);
echo("ru: ", ru); echo(ru=ru);
echo("rl: ", rl); echo(rl=rl);
echo("width: ", width); echo(width=width);
translate([0,-max(ru,rl),ht*3/4+.5]) translate([0, -max(ru,rl), ht*3/4+.5])
rotate([90,0,0]) rotate([90, 0, 0])
scale([1,1,1]) scale([1, 1, 1])
scale([ht/100,ht/100,1]) scale([ht/100, ht/100, 1])
translate([0, -ht/2,0]) translate([0, -ht/2, 0])
rotate(-90, [0, 0, 1]) rotate(-90, [0, 0, 1])
catear_headband( catear_headband(
size=ear_size, size=ear_size,
height=max(ru,rl), height=max(ru, rl),
thickness=width, thickness=width,
stretch_len=0, stretch_len=0,
tip_len=0, tip_len=0,
@ -114,38 +123,38 @@ module logo(logo, rl, ht, ru, width) {
with_rake=false with_rake=false
); );
} else { } else {
// The logo has been split in 3 parts. // well was... TODO // The logo has been split in 3 parts. // well was... TODO
/* /*
rotate([0,0,-48]) translate([0,0,ht*3/4-0.1]) rotate([0, 0, -48]) translate([0, 0, ht*3/4-0.1])
rotate([90,0,0]) rotate([90, 0, 0])
scale([0.9,0.9,1]) scale([0.9, 0.9, 1])
scale([ht/100,ht/100,1]) scale([ht/100, ht/100, 1])
translate([-25,-29,0.5]) translate([-25, -29, 0.5])
linear_extrude(height=max(ru,rl)*2) linear_extrude(height=max(ru,rl)*2)
import("logo_1.dxf"); import("logo_1.dxf");
*/ */
translate([0,0,ht*3/4-0.1]) translate([0, 0, ht*3/4-0.1])
rotate([90,0,0]) rotate([90, 0, 0])
scale([0.8,0.8,1]) scale([0.8, 0.8, 1])
scale([ht/100,ht/100,1]) scale([ht/100, ht/100, 1])
translate([-18,-22,0.5]) translate([-18, -22, 0.5])
linear_extrude(height=max(ru,rl)*2) linear_extrude(height=max(ru, rl)*2)
import(logo); import(logo);
/* /*
rotate([0,0,44]) translate([0,0,ht*3/4-0.1]) rotate([0, 0, 44]) translate([0, 0, ht*3/4-0.1])
rotate([90,0,0]) rotate([90, 0, 0])
scale([0.7,0.7,1]) scale([0.7, 0.7, 1])
scale([ht/100,ht/100,1]) scale([ht/100, ht/100, 1])
translate([-25,-26,0.5]) translate([-25, -26, 0.5])
linear_extrude(height=max(ru,rl)*2) linear_extrude(height=max(ru,rl)*2)
import("logo_3.dxf"); import("logo_3.dxf");
*/ */
} }
} }
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]) { rotate([0, 0, -45]) {
// main cylinder // main cylinder
if (RENDER_COLOR_ONE) { if (RENDER_COLOR_ONE) {
color("black") difference() { color("black") difference() {
@ -157,12 +166,12 @@ module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="c3cat", font="write/o
} }
cylinder(r1=rl+width/2, r2=ru+width/2, h=ht); cylinder(r1=rl+width/2, r2=ru+width/2, h=ht);
} }
translate([0,0,-1]) translate([0, 0, -1])
cylinder(r1=rl, r2=ru, h=ht+2); cylinder(r1=rl, r2=ru, h=ht+2);
// finally, substract a cube as a gap so we can clip it to the bottle // finally, subtract a cube as a gap so we can clip it to the bottle
rotate([0, 0, 45]) rotate([0, 0, 45])
translate([0,0,-1]) translate([0, 0, -1])
cube([50,50,50]); cube([50, 50, 50]);
} }
} }
// text // text
@ -185,11 +194,11 @@ module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="c3cat", font="write/o
} }
module outer_cutoff(rl, e, ru, ht, width) { module outer_cutoff(rl, e, ru, ht, width) {
// outer cylinder which is substracted, so the text and the logo end // outer cylinder which is subtracted, so the text and the logo end
// somewhere on the outside ;-) // somewhere on the outside ;-)
difference () { difference () {
cylinder(r1=rl+e, r2=ru+e, h=ht); cylinder(r1=rl+e, r2=ru+e, h=ht);
translate([0,0,-1]) translate([0, 0, -1])
// Note: bottom edges of characters are hard to print when character // Note: bottom edges of characters are hard to print when character
// depth is > 0.7 // depth is > 0.7
cylinder(r1=rl+width+0.7, r2=ru+width+0.7, h=ht+2); cylinder(r1=rl+width+0.7, r2=ru+width+0.7, h=ht+2);