121 lines
3.5 KiB
OpenSCAD
121 lines
3.5 KiB
OpenSCAD
//
|
|
// Parametric Split-Flap Generator V1.0
|
|
// (c) Dennis Gunia 2025 - www.dennisgunia.de
|
|
//
|
|
// Generates printable 3d multi-material model for each flap!
|
|
//
|
|
flap_width = 42.8*1; // flap width
|
|
flap_height = 35; // flap height
|
|
flap_thickness = 1; // flap thickness
|
|
flap_recess = 18; // recessed area in mm
|
|
flap_recess_width = 2; // recessed area width
|
|
flap_tap_width = 1; // flap tap width (shoud be smaller than d)
|
|
flap_tap_offset = 1; // margin to flap top
|
|
|
|
char_bottom = "A"; // char for front (top)
|
|
char_top = "W"; // char for back (previous)
|
|
|
|
// alternate SVG
|
|
svg_top = "";
|
|
svg_top_scale = 0.8;
|
|
svg_bottom = "";
|
|
svg_bottom_scale = 0.8;
|
|
|
|
|
|
// Font settings
|
|
font_bottom = "TW Cen MT Condensed:style=Bold";
|
|
font_bottom_size = 40;
|
|
font_bottom_y_scale = 1.3;
|
|
|
|
font_top = "TW Cen MT Condensed:style=Bold";
|
|
font_top_size = 40;
|
|
font_top_y_scale = 1.3;
|
|
|
|
// export step
|
|
exp_step = 0;
|
|
|
|
// Generate single sided text
|
|
module text2d(t, size, font, rotate180=false, y_scale){
|
|
rotate(rotate180 ? 180 : 0)
|
|
scale([1,y_scale])
|
|
text(t, size=size, font=font, halign="center", valign="center");
|
|
}
|
|
|
|
// Generate base
|
|
module base_plate(){
|
|
color([0.1,0.1,0.1])
|
|
translate([0,flap_height/-2,0]){
|
|
union(){
|
|
linear_extrude(flap_thickness)
|
|
square([flap_width - flap_recess_width*2, flap_height], center=true);
|
|
//generate tab
|
|
translate([(flap_width/2)*-1,flap_height/2-(flap_tap_offset+flap_tap_width),0]){
|
|
linear_extrude(flap_thickness)
|
|
square([flap_width, flap_tap_width]);
|
|
};
|
|
// generate lower part
|
|
translate([(flap_width/2)*-1,(flap_height/2)*-1,0]){
|
|
linear_extrude(flap_thickness)
|
|
square([flap_width, flap_height-flap_recess]);
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
// Generate and translate Text
|
|
module text_component(str_bottom, str_top,oversize){
|
|
if (len(svg_bottom) == 0){
|
|
// generate bottom text
|
|
translate([0,0,-oversize]){
|
|
mirror([1,0,0])
|
|
linear_extrude(height=0.4+oversize)
|
|
text2d(str_bottom,font_top_size,font_bottom,false,font_bottom_y_scale);
|
|
}
|
|
} else {
|
|
// generate bottm shape from svg
|
|
translate([0,0,-oversize]){
|
|
mirror([1,0,0])
|
|
linear_extrude(height=0.4+oversize)
|
|
scale([svg_bottom_scale,svg_bottom_scale])
|
|
import(svg_bottom, center=true);
|
|
}
|
|
}
|
|
if (len(svg_top) == 0){
|
|
// generate top text
|
|
translate([0,0,flap_thickness-0.4+oversize]){
|
|
linear_extrude(height=0.4+oversize)
|
|
text2d(str_top,font_top_size,font_top,true,font_top_y_scale);
|
|
}
|
|
} else {
|
|
// generate bottm shape from svg
|
|
translate([0,0,flap_thickness-0.4+oversize]){
|
|
rotate(180)
|
|
linear_extrude(height=0.4+oversize)
|
|
scale([svg_top_scale,svg_top_scale])
|
|
import(svg_top, center=true);
|
|
}
|
|
}
|
|
}
|
|
|
|
// assemble final flap
|
|
module base(){
|
|
difference(){
|
|
base_plate();
|
|
text_component(char_bottom,char_top,0.1);
|
|
}
|
|
}
|
|
module txt1(){
|
|
difference(){
|
|
color("white")
|
|
text_component(char_bottom,char_top,0.0);
|
|
translate([flap_width/-2,0,-0.1]) cube([flap_width,flap_height,flap_thickness+0.2]);
|
|
}
|
|
}
|
|
if (exp_step == 0){
|
|
group("base")
|
|
base();
|
|
} else {
|
|
group("text")
|
|
txt1();
|
|
}
|