Last active
April 10, 2019 13:40
-
-
Save alexws54tk/a1ffd52987d0ad4e62aa0b269ae17f36 to your computer and use it in GitHub Desktop.
OpenSCAD chemical element `card.scad`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
width=60; // width of card | |
height=40; // height of card | |
// code="Th"; | |
elements = ["", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", | |
"Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", | |
"V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", | |
"Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", | |
"Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", | |
"Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", | |
"Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", | |
"Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", | |
"Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", | |
"Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og" | |
/*, "Uue", "Ubn", "Ubu", "Ubb", "Ubt", "Ubq", "Ubp", "Ubh", "Ubs" */ | |
]; // from https://ru.wikipedia.org/wiki/Список_химических_элементов | |
number=42; // [1:1:118] | |
type="both"; // [1:card, 2:text, 3:both] | |
font="PT Mono"; // font of text label | |
$fn=36; | |
if (type=="card") { | |
card(); // Generate card only. Need once. | |
} else if (type=="text") { | |
label(); // Generate text label only. | |
} else { | |
union() { // Generate card with label. | |
card(); | |
label(); | |
} | |
} | |
module card() { | |
color("lightgrey") | |
linear_extrude(1) | |
square([width, height]); | |
} | |
module label() { | |
translate([0,0,0.9]) | |
union () { | |
color("red") // Name of element | |
translate([2, height/2-2]) | |
linear_extrude(1.1) | |
text(elements[number], font=font, halign="left", valign="center", size=height/1.6); | |
color("green") // Number of element | |
translate([width-2, height-3]) | |
linear_extrude(1.1) | |
text(str(number), font=font, halign="right", valign="top", size=height/3.5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment