-
Notifications
You must be signed in to change notification settings - Fork 9
/
bottle-clip.scad
144 lines (135 loc) · 5.95 KB
/
bottle-clip.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
* A name tag that can easily be clipped to the neck of your bottle.
* Copyright (C) 2013 Roland Hieber <[email protected]>
*
* See examples.scad for examples on how to use this module.
*
* The contents of this file are licenced under CC-BY-SA 3.0 Unported.
* See https://creativecommons.org/licenses/by-sa/3.0/deed for the
* licensing terms.
*/
include <write/Write.scad>
/**
* Module for multi colored print.
* All children are the given color.
* Using the global CURRENT_COLOR it is possible to only render and export everything of one color.
* Doing this for all colors the resulting stls can be put together again to a multi filament print in the slicer.
* If CURRENT_COLOR is set to "ALL" all colors are displayed.
* If color is "DEFAULT", it is not colored in the preview.
* Inspired by https://erik.nygren.org/2018-3dprint-multicolor-openscad.html
*/
module multicolor(color) {
if (is_undef(CURRENT_COLOR) || CURRENT_COLOR == "ALL" || CURRENT_COLOR == color) {
if (color != "DEFAULT") {
color(color) children();
} else {
children();
}
}
}
/**
* Creates one instance of a bottle clip name tag. The default values are
* suitable for 0.5l Club Mate bottles (and similar bottles). By default, logo
* and text are placed on the name tag so they both share half the height. If
* there is no logo, the text uses the total height instead.
* Parameters:
* ru: the radius on the upper side of the clip
* rl: the radius on the lower side of the clip
* ht: the height of the clip
* width: the thickness of the wall. Values near 2.5 usually result in a good
* clippiness for PLA prints.
* 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.
* gap: width of the opening gap, in degrees. For rigid materials this value
* usually needs to be near 180 (but if you set it to >= 180, you won't have
* anything left for holding the clip on the bottle). For flexible materials
* like Ninjaflex, choose something near 0. For springy materials like PLA or
* ABS, 90 has proven to be a good value.
* logo: the path to a DXF file representing a logo that should be put above
* the name. Logo files should be no larger than 50 units in height and should
* be centered on the point (25,25). Also all units in the DXF file should be
* in mm. This parameter can be empty; in this case, the text uses the total
* height of the name tag.
* font: the path to a font for Write.scad.
* bg_color: The color of the background (the clip itself)
* text_color: The color of the text
* logo_color: The color of the logo
*/
module bottle_clip(ru=13, rl=17.5, ht=26, width=2.5, name="", gap=90,
logo="thing-logos/stratum0-lowres.dxf", font="write/orbitron.dxf",
bg_color="DEFAULT", text_color="DEFAULT", logo_color="DEFAULT") {
e=100; // should be big enough, used for the outer boundary of the text/logo
difference() {
rotate([0,0,-45]) union() {
// main cylinder
multicolor(bg_color) cylinder(r1=rl+width, r2=ru+width, h=ht);
// text and logo
if(logo == "") {
multicolor(text_color) writecylinder(name, [0,0,3], rl+0.5, ht/13*7, h=ht/13*8, t=max(rl,ru),
font=font);
} else {
multicolor(text_color) writecylinder(name, [0,0,0], rl+0.5, ht/13*7, h=ht/13*4, t=max(rl,ru),
font=font);
multicolor(logo_color) translate([0,0,ht*3/4-0.1])
rotate([90,0,0])
scale([ht/100,ht/100,1])
translate([-25,-25,0.5])
linear_extrude(height=max(ru,rl)*2)
import(logo);
}
}
// inner cylinder which is substracted
translate([0,0,-1])
cylinder(r1=rl, r2=ru, h=ht+2);
// outer cylinder which is substracted, so the text and the logo end
// somewhere on the outside ;-)
difference () {
cylinder(r1=rl+e, r2=ru+e, h=ht);
translate([0,0,-1])
// Note: bottom edges of characters are hard to print when character
// depth is > 0.7
cylinder(r1=rl+width+0.7, r2=ru+width+0.7, h=ht+2);
}
// finally, substract an equilateral triangle as a gap so we can clip it to
// the bottle
gap_x=50*sin(45-gap/2);
gap_y=50*cos(45-gap/2);
translate([0,0,-1])
linear_extrude(height=50)
polygon(points=[[0,0], [gap_x, gap_y], [50,50], [gap_y, gap_x]]);
}
}
/**
* Creates one instance of a bottle clip name tag suitable for 0.33l longneck
* bottles (like fritz cola, etc.). All parameters are passed to the module
* bottle_clip(), see there for their documentation.
*/
module bottle_clip_longneck(name="", width=2.5, gap=90,
logo="thing-logos/stratum0-lowres.dxf", font="write/orbitron.dxf",
bg_color="DEFAULT", text_color="DEFAULT", logo_color="DEFAULT") {
bottle_clip(name=name, ru=13, rl=15, ht=26, width=width, logo=logo, gap=gap,
font=font, bg_color=bg_color, text_color=text_color, logo_color=logo_color);
}
/**
* Creates one instance of a bottle clip name tag suitable for 0.33l DIN 6199
* beer bottles (also known as "Steinie", "Stubbi", "Knolle", etc.). Because of
* reasons, there is no logo, but all other parameters are passed to the module
* bottle_clip(), see there for their documentation.
*/
module bottle_clip_steinie(name="", width=2.5, gap=90, font="write/orbitron.dxf",
bg_color="DEFAULT", text_color="DEFAULT", logo_color="DEFAULT") {
bottle_clip(name=name, ru=13, rl=17.5, ht=13, width=width, logo="", gap=gap,
font=font, bg_color=bg_color, text_color=text_color, logo_color=logo_color);
}
/*
* Create one instance of a bottle clip name tag suitable for 0.5l DIN 6198
* bottle (also known as "Euroflasche" or "Euroform 2"). All parameters are
* passed to the module bottle_clip(), see there for their documentation.
*/
module bottle_clip_euro2(name="", width=2.5, gap=90,
logo="thing-logos/stratum0-lowres.dxf", font="write/orbitron.dxf",
bg_color="DEFAULT", text_color="DEFAULT", logo_color="DEFAULT") {
bottle_clip(name=name, ru=13, rl=22.5, ht=26, width=width, logo=logo, gap=gap,
font=font, bg_color=bg_color, text_color=text_color, logo_color=logo_color);
}
// vim: set noet ts=2 sw=2 tw=80: