Skip to content

Instantly share code, notes, and snippets.

@Shyru
Created April 20, 2024 00:14
Show Gist options
  • Save Shyru/b936927cd06dc66e0ad2cdb9f196c49a to your computer and use it in GitHub Desktop.
Save Shyru/b936927cd06dc66e0ad2cdb9f196c49a to your computer and use it in GitHub Desktop.
Test-Cube OpenSCAD Parametric Model
/**
* Test-Cube Version 0.1
* https://makerworld.com/en/models/435620
*
* Date: 2024-04-20
* Author: Daniel Haas
* Copyright: Daniel Haas 2004
* License: CC BY-NC-ND 4.0 DEED (https://creativecommons.org/licenses/by-nc-nd/4.0/)
*/
//The size of the cube
cube_size = 30; //[20:5:100]
//The name of the filament that you will be using for the test print
filament = "PLA";
//If texts should be etched into the cube or not
etch_texts = false;
//The layer height you will be using for the test print (in mm)
/* [Printing parameters] */
layer_height = "0.2";
//The extruder temperature you will be using for the test print
extruder_temperature = 220;
//The print-bed temperature you will be using for the test print
printbed_temperature = 55;
//The infill density you will be using for the test print
infill_density = 15;
/* [Additional Text] */
//First line of additional text that may be printed on the text cube on another side.
additional_text1 = "";
//Second line of additional text that may be printed on the text cube on another side.
additional_text2 = "";
//Third line of additional text that may be printed on the text cube on another side.
additional_text3 = "";
//Fourth line of additional text that may be printed on the text cube on another side.
additional_text4 = "";
/* [Advanced] */
//the unit the temperatures are in
temperature_unit="°C"; //["°C","°F"]
$fa = 1;
$fs = 0.2;
difference() {
cube(cube_size);
translate([cube_size/2,-cube_size/4,cube_size/2.5])
rotate([-45,0,0])
cylinder(cube_size*1.2,cube_size/7,cube_size/7);
if (etch_texts) {
add_material_names();
add_parameters();
add_additional_texts();
}
}
if (!etch_texts)
{
add_material_names();
add_parameters();
add_additional_texts();
}
//adds the material name to all sides of the cube
module add_material_names() {
text_offset = cube_size/80;
font_size = cube_size/6.5;
text_padding = cube_size/20;
//front text (hole)
translate([text_padding,text_offset,text_padding])
rotate([90,0,0])
linear_extrude(cube_size/40)
text(filament,font_size,font = "Arial:style=Bold");
//right text
translate([cube_size-text_offset,text_padding,text_padding])
rotate([90,0,90])
linear_extrude(cube_size/40)
text(filament,font_size,font = "Arial:style=Bold");
//left text
translate([text_offset,cube_size-text_padding,text_padding])
rotate([90,0,-90])
linear_extrude(cube_size/40)
text(filament,font_size,font = "Arial:style=Bold");
//back text
translate([cube_size-text_padding,cube_size-text_offset,text_padding])
rotate([90,0,180])
linear_extrude(cube_size/40)
text(filament,font_size,font = "Arial:style=Bold");
}
module add_parameters() {
text_offset_3d = cube_size/80;
text_padding = cube_size/40;
font_size = cube_size/8;
translate([cube_size-text_offset_3d,text_padding,cube_size-text_padding*1-font_size*1])
rotate([90,0,90])
linear_extrude(cube_size/40)
text(str(layer_height," mm"),font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,text_padding,cube_size-text_padding*2-font_size*2])
rotate([90,0,90])
linear_extrude(cube_size/40)
text(str(extruder_temperature," ",temperature_unit),font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,text_padding,cube_size-text_padding*3-font_size*3])
rotate([90,0,90])
linear_extrude(cube_size/40)
text(str(printbed_temperature," ",temperature_unit),font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,text_padding,cube_size-text_padding*4-font_size*4])
rotate([90,0,90])
linear_extrude(cube_size/40)
text(str(infill_density," %"),font_size,font = "Arial:style=Bold");
}
module add_additional_texts() {
text_offset_3d = cube_size/80;
text_padding = cube_size/40;
font_size = cube_size/8;
translate([cube_size-text_offset_3d,cube_size-text_offset_3d,cube_size-text_padding*1-font_size*1])
rotate([90,0,180])
linear_extrude(cube_size/40)
text(additional_text1,font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,cube_size-text_offset_3d,cube_size-text_padding*2-font_size*2])
rotate([90,0,180])
linear_extrude(cube_size/40)
text(additional_text2,font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,cube_size-text_offset_3d,cube_size-text_padding*3-font_size*3])
rotate([90,0,180])
linear_extrude(cube_size/40)
text(additional_text3,font_size,font = "Arial:style=Bold");
translate([cube_size-text_offset_3d,cube_size-text_offset_3d,cube_size-text_padding*4-font_size*4])
rotate([90,0,180])
linear_extrude(cube_size/40)
text(additional_text4,font_size,font = "Arial:style=Bold");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment