Compare commits

..

No commits in common. "350b76c8674e5d6aa3c7515124a0fd3e41614dac" and "db32cff7044747cc4b76a23391361ea75d2f0ea3" have entirely different histories.

View File

@ -1,17 +1,14 @@
include <BOSL2/std.scad> include <BOSL2/std.scad>
include <Typography/typo.scad>
A4_LANDSCAPE= [297,210]; A4_LANDSCAPE= [297,210];
title_block_debugging = false;
experimental = true; debugging = false;
module titleBlock( module titleBlock(
project, project,
title = undef,
description = "",
textSize=6, textSize=6,
date="2025-01-01", date="2025-01-01",
scale=1, scale=1,
@ -20,137 +17,87 @@ module titleBlock(
inset=10, inset=10,
anchor=CENTER, anchor=CENTER,
spin=0, spin=0,
orient=UP, orient=UP
color="Black",
strokeWidth = 0.5,
page="A4",
landscape = true,
//anchor=CENTER,spin=0,orient=LEFT //anchor=CENTER,spin=0,orient=LEFT
) { ) {
w = rect[0]; w = rect[0];
h = rect[1]; h = rect[1];
interline = 7;
_inset = inset> 0 ? inset : h/20; _inset = inset> 0 ? inset : h/20;
//path = rect([w,h], chamfer=0 /*, anchor=FRONT*/); echo("w",w);
attachable(anchor,spin,orient, size=[w,h,50]) { echo("h",h);
projection( cut = false ) recolor(color) union() { echo("inset",_inset);
// ************ Frame *************** // Border
rect_tube(size=[w,h], wall=0.5, h=0.1); path = rect([w,h], chamfer=0 /*, anchor=FRONT*/);
l1 = h/2 - _inset; //color("Blue")
l2 = l1 - interline- 2*_inset ;
// ************ Project ***************
translate([-w /2+_inset, l1 ])
linear_extrude(0.1)
text(project, size=textSize,halign="left",anchor=TOP,font="Saira Stencil One");
// ************ Scale *************** //back(-50/2)
translate([w/2-_inset, l1])
linear_extrude(0.1) //square(rect, center=true);
text(str("Scale: 1/",scale), size=textSize*2/5,halign="right",anchor=TOP);
// ************ Title *************** //attachable( anchor,orient,/*anchor, spin, orient,*/size=[w,h,0] /*,axis=RIGHT*/ ) {
//metrics = textmetrics(project, size=textSize, font="Saira Stencil One"); attachable(anchor,spin,orient, size=[w,h,50]) {
//l2 = l1 - metrics.size[1]- 2*_inset ; union() {
if ( title ) stroke(path, closed=true);
translate([-w /2+_inset, l2 ]) // Title
linear_extrude(0.1) text( title, size=textSize*2/3,halign="left",anchor=TOP,font="Arial Black"); translate([-w /2+_inset, h/2 - _inset ])
// ************ Description *************** text(project, size=textSize,halign="left",anchor=TOP);
if ( description ) { // Revision
translate([ -8, l2 - _inset/2 ]) translate([-w /2+_inset, -h/2 + _inset])
linear_extrude(0.1) text(str("Revision:",revision), size=textSize*2/3/*,anchor=BOTTOM*/);
smartText( // Scale
description, translate([w/2-_inset, h/2 - _inset])
size=textSize*1/4, text(str("Scale: 1:",scale), size=textSize*2/3,halign="right",anchor=TOP);
halign="left", // Date
font="Arial", translate([w/2-_inset, -h/2 + _inset])
style="italic", text(str("Date:",date), size=textSize*2/3,halign="right");
max_width = 51
);
}
h1 = h/2-2*_inset - interline;
translate([-w/2+_inset,h1,0]) cube([w-2*_inset,0.1,0.1]);
// ************ Vertical sep ***************
translate([10,interline-1*_inset/2,0]) cube([0.1,interline,0.1]);
// ************ Revision ***************
translate([-w /2+_inset+14, -h/2 + 2*_inset]) {
linear_extrude(0.1) text("Revision:", size=textSize*2/5, anchor = RIGHT, font = "Arial:style=Italic");
linear_extrude(0.1) text(str(revision), size=textSize*2/5, anchor = LEFT,font = "Arial:style=Bold");
}
// ************ Date ***************
translate([w/2-_inset-16, -h/2 + 2*_inset]) {
linear_extrude(0.1) text("Date:", size=textSize*2/5,halign="right", anchor = RIGHT, font = "Arial:style=Italic");
linear_extrude(0.1) text(str(date), size=textSize*2/5, anchor = LEFT,font = "Arial:style=Bold");
}
}; };
children(); children();
}; };
} }
module A4( margin = 10, landscape = true, onlyMargin = true, anchor=CENTER, spin=0, orient=UP, scale=1, strokeWidth=0.2 ){ module A4( margin = 10, landscape = true, onlyMargin = true, anchor=CENTER, spin=0, orient=UP ){
//a4= [297,210];
w = A4_LANDSCAPE[0]; w = A4_LANDSCAPE[0];
h = A4_LANDSCAPE[1]; h = A4_LANDSCAPE[1];
marginW = w-2*margin; marginW = w-2*margin;
marginH = h-2*margin; marginH = h-2*margin;
contour = rect([w,h]);
attachable(anchor,spin, orient, size=[marginW,marginH,50]) { //translate([w/2,h/2,0])
projection( cut = false ) union(){ //attachable(size=[100,200,0] ) {
if (!onlyMargin) // attachable( /*anchor=anchor, , spin, orient,*/size=[marginW,marginH,0] ) {
color("Orange") attachable(anchor,spin,orient, size=[marginW,marginH,50]) {
rect_tube(size=[w,h], wall=0.1, h=0.1);
color("Red") union(){
rect_tube(size=[marginW,marginH], wall=0.1, h=0.1);
if (!onlyMargin) color("Orange") stroke(contour, closed=true);
marginPath = rect([marginW,marginH]);
color("Red") stroke(marginPath, closed=true);
}; };
//}
children(); children();
} }
} }
module plan(
project,
title = undef, if ( debugging ) {
description = "", //titleBlock("My First Project");
textSize = 6,
date = "2025-01-01", A4( onlyMargin = false,anchor=LEFT+FWD )
scale = 1,
revision = "1a",
page = "A4"
)
{
A4( onlyMargin = false, anchor=LEFT+FWD, scale=2 ) {
//align(align=TOP+LEFT+FWD,spin=[0, 0, 0],inside=true) //align(align=TOP+LEFT+FWD,spin=[0, 0, 0],inside=true)
//attach(LEFT+FWD,/*RIGHT,inside=true*/) //attach(LEFT+FWD,/*RIGHT,inside=true*/)
//align(LEFT,inside=true) //align(LEFT,inside=true)
if (true) align( FWD+RIGHT,inside=true ) { align(FWD+RIGHT,inside=true)
titleBlock( titleBlock("Metal Desk",textSize=7,rect=[90,30],inset=2);
project, //cuboid([50,20,10],anchor=TOP);
title = title,
description = description,
//textSize = 7,
rect = [90,30],
inset = 2
);
};
align(BACK+LEFT,inside=true) {
children();
}
}
}
if ( title_block_debugging ) {
//titleBlock("My First Project");
lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at rutrum magna. Donec auctor euismod nulla ut congue.";
plan(
"Title Block",
title="Sub title",
description=lorem,
) {
//projection( cut = false ) cube([100,100,100]);
}
} }