poker-chips/chip.scad

68 lines
1.7 KiB
OpenSCAD

// Diameter of the coin (mm)
diameter = 39;
// Height of the coin (mm)
height = 3.5;
// Engraving depth (mm)
depth = 0.5;
// Number of sides on your coin
sides = 360; // [3:360]
// How many holes (spokes) do you want?
holes = 6; // [0:12]
// Text to display
text = "100";
// The font must be installed locally on your system
font = "Droid Sans:style=Bold";
fontScale = (
sides == 3 ? 0.50
: sides == 4 ? 0.80
: sides == 5 ? 0.80
: sides == 6 ? 0.90
: 1.00
);
// Enough width to fit four digits
fontSize = diameter * 0.21 * fontScale;
// Rotate odd-numbers of sides to maximize width
rotation = (sides%2)?90:0;
module chip() {
intersection() {
cylinder(h=height, d=diameter, center=true, $fn=sides);
union() {
difference() {
cube([diameter, diameter, height], center=true);
difference() {
cylinder(h=height, d=diameter*0.8, center=true, $fn=sides);
cylinder(h=height, d=diameter*0.7, center=true, $fn=sides);
}
}
if (holes == 0) {
cube([diameter, diameter, height*0.7], center=true);
} else {
spokeWidth = (diameter/holes) * 0.8;
rotate((sides+holes)%2?90:0) {
for (i = [0 : 360/holes : 360]) {
rotate(i) translate([diameter/2, 0, 0]) cube([diameter, spokeWidth, height*0.7], center=true);
}
}
}
}
}
}
difference() {
rotate(rotation) chip();
translate([0, 0, height/2-depth])
linear_extrude(height=depth+0.1, convexity = 10, twist = 0)
text(text=text, font=font, size=fontSize, halign="center", valign="center");
}