Compare commits

..

2 Commits

Author SHA1 Message Date
350b76c867 Fix for render 2025-02-17 12:08:01 -03:00
a13e2a7399 3d Rendering fix 2025-02-17 11:13:15 -03:00

View File

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