Skip to content

Instantly share code, notes, and snippets.

@ridercz
Created March 8, 2022 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridercz/39acbc387f50390c7741e9a4d7721408 to your computer and use it in GitHub Desktop.
Save ridercz/39acbc387f50390c7741e9a4d7721408 to your computer and use it in GitHub Desktop.
Jmenovky na ohlávky v OpenSCADu
/* [Preview] */
base_color = "#333";
text_color = "#ddd";
/* [Text] */
// Displayed text
text = "ALTAIR";
// Displayed text font
text_font = "Arial Rounded MT Bold";
// Nominal font size
text_size = 14; // [6:20]
// Extrusion height
text_thickness = .4; // [.2:.2:3]
/* [Shape] */
// Space around the letters
base_padding = 3; // [0:10]
// Thickness of base under letters
base_thickness = 1; // [.2:.2:3]
// Check to hull all base outlines
base_solid = false;
/* [Mount holes] */
// Distance of hole centers
hole_span = 73; // [10:100]
// Mount hole diameter
hole_diameter = 4.5; // [2:.5:6]
// Space around the holes
hole_padding = 4; // [2:10]
// Compute dimensions
total_height = text_size + 2 * base_padding;
total_width = hole_span + hole_diameter + 2 * hole_padding;
total_thickness = base_thickness + text_thickness;
echo(computed_dimensions = [total_width, total_height, total_thickness]);
// The tag base
color(base_color) linear_extrude(base_thickness) difference() {
base_transform(base_solid) {
offset(base_padding) text(text = text, size = text_size, font = text_font, halign = "center", valign = "center");
hull() {
translate([-hole_span / 2, 0]) circle(d = hole_diameter + 2 * hole_padding, $fn = 64);
translate([+hole_span / 2, 0]) circle(d = hole_diameter + 2 * hole_padding, $fn = 64);
}
}
// Mount holes
translate([-hole_span / 2, 0]) circle(d = hole_diameter, $fn = 64);
translate([+hole_span / 2, 0]) circle(d = hole_diameter, $fn = 64);
}
// Extruded text
color(text_color)
translate([0, 0, base_thickness])
linear_extrude(text_thickness)
text(text = text, size = text_size, font = text_font, halign = "center", valign = "center");
// Helper conditional transformation
module base_transform(solid) {
if(solid) {
hull() children();
} else {
union() children();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment