Quote and a4 page with title block
This commit is contained in:
parent
a184d02d41
commit
db32cff704
6
.gitignore
vendored
6
.gitignore
vendored
@ -1 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.swp
|
||||||
|
|
||||||
|
|
||||||
|
## Customizers presets
|
||||||
|
quotes.json
|
||||||
|
titleBlock.json
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
## Setup soft link
|
## Setup soft link
|
||||||
|
|
||||||
|
Make a symbolic link to make the quotes library available as library
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ln -s /Users/sursini/Documents/Design/OpenSCAD Quotes
|
ln -s /Users/sursini/Documents/Design/OpenSCAD/Quotes /usr/local/share/openscad/libraries/Quotes
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
65
quotes.scad
Normal file
65
quotes.scad
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
include <BOSL2/std.scad>
|
||||||
|
|
||||||
|
|
||||||
|
debugging = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quote
|
||||||
|
*
|
||||||
|
* @param offsetFromOrigin - It specifies the distance from the object being dimensioned to the start of the extension lines
|
||||||
|
* @param extendBeyondDimLines - How much the extension lines extend past the dimension line
|
||||||
|
* @param textOffset - Distance between dimension text and dimension line
|
||||||
|
* @param direction - Direction of the dimension line (RIGHT, LEFT, UP, DOWN)
|
||||||
|
* @param placement - If BOTTOM, places the dimension below the model; if TOP, above (default is TOP)
|
||||||
|
*/
|
||||||
|
module quote(
|
||||||
|
length,
|
||||||
|
offsetFromOrigin = 140,
|
||||||
|
extendBeyondDimLines = 40,
|
||||||
|
textOffset = 10,
|
||||||
|
direction = RIGHT,
|
||||||
|
color = "Red",
|
||||||
|
placement = TOP
|
||||||
|
){
|
||||||
|
|
||||||
|
// Determine rotation angle based on direction
|
||||||
|
angle =
|
||||||
|
direction == RIGHT ? 0 :
|
||||||
|
direction == LEFT ? 180 :
|
||||||
|
direction == UP ? 90 :
|
||||||
|
direction == DOWN ? -90 : 0;
|
||||||
|
|
||||||
|
// Adjust offset based on whether the dimension is under the model
|
||||||
|
actualOffset = placement == BOTTOM ? -offsetFromOrigin : offsetFromOrigin;
|
||||||
|
|
||||||
|
// Use color
|
||||||
|
color(color) {
|
||||||
|
// Rotate everything according to the direction
|
||||||
|
zrot(angle) {
|
||||||
|
path = [[ 0, actualOffset], [length-5 , actualOffset ]];
|
||||||
|
// Paralel line
|
||||||
|
stroke(path, width = 3,endcaps = "arrow2",endcap_width = 15);
|
||||||
|
|
||||||
|
// Extension Line 1
|
||||||
|
ext1 = [[0,0], [0,actualOffset + (placement == BOTTOM ? -extendBeyondDimLines : extendBeyondDimLines)]];
|
||||||
|
stroke(ext1, width=3);
|
||||||
|
|
||||||
|
// Extension Line 2
|
||||||
|
ext2 = [[length,0], [length,actualOffset + (placement == BOTTOM ? -extendBeyondDimLines : extendBeyondDimLines)]];
|
||||||
|
stroke(ext2, width=3);
|
||||||
|
|
||||||
|
// Text
|
||||||
|
back( actualOffset + textOffset )
|
||||||
|
right(length/2)
|
||||||
|
text(str(length), size=60, font="Saira Stencil One", halign="center");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( debugging )
|
||||||
|
quote(1000,direction=RIGHT,placement=BOTTOM);
|
103
titleBlock.scad
Normal file
103
titleBlock.scad
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
include <BOSL2/std.scad>
|
||||||
|
|
||||||
|
|
||||||
|
A4_LANDSCAPE= [297,210];
|
||||||
|
|
||||||
|
|
||||||
|
debugging = false;
|
||||||
|
|
||||||
|
module titleBlock(
|
||||||
|
project,
|
||||||
|
textSize=6,
|
||||||
|
date="2025-01-01",
|
||||||
|
scale=1,
|
||||||
|
revision="1a",
|
||||||
|
rect=[90,30],
|
||||||
|
inset=10,
|
||||||
|
anchor=CENTER,
|
||||||
|
spin=0,
|
||||||
|
orient=UP
|
||||||
|
//anchor=CENTER,spin=0,orient=LEFT
|
||||||
|
|
||||||
|
) {
|
||||||
|
w = rect[0];
|
||||||
|
h = rect[1];
|
||||||
|
_inset = inset> 0 ? inset : h/20;
|
||||||
|
echo("w",w);
|
||||||
|
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]) {
|
||||||
|
union() {
|
||||||
|
stroke(path, closed=true);
|
||||||
|
// Title
|
||||||
|
translate([-w /2+_inset, h/2 - _inset ])
|
||||||
|
text(project, size=textSize,halign="left",anchor=TOP);
|
||||||
|
// Revision
|
||||||
|
translate([-w /2+_inset, -h/2 + _inset])
|
||||||
|
text(str("Revision:",revision), size=textSize*2/3/*,anchor=BOTTOM*/);
|
||||||
|
// Scale
|
||||||
|
translate([w/2-_inset, h/2 - _inset])
|
||||||
|
text(str("Scale: 1:",scale), size=textSize*2/3,halign="right",anchor=TOP);
|
||||||
|
// Date
|
||||||
|
translate([w/2-_inset, -h/2 + _inset])
|
||||||
|
text(str("Date:",date), size=textSize*2/3,halign="right");
|
||||||
|
};
|
||||||
|
children();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module A4( margin = 10, landscape = true, onlyMargin = true, anchor=CENTER, spin=0, orient=UP ){
|
||||||
|
|
||||||
|
//a4= [297,210];
|
||||||
|
w = A4_LANDSCAPE[0];
|
||||||
|
h = A4_LANDSCAPE[1];
|
||||||
|
marginW = w-2*margin;
|
||||||
|
marginH = h-2*margin;
|
||||||
|
contour = rect([w,h]);
|
||||||
|
|
||||||
|
//translate([w/2,h/2,0])
|
||||||
|
//attachable(size=[100,200,0] ) {
|
||||||
|
// attachable( /*anchor=anchor, , spin, orient,*/size=[marginW,marginH,0] ) {
|
||||||
|
attachable(anchor,spin,orient, size=[marginW,marginH,50]) {
|
||||||
|
|
||||||
|
union(){
|
||||||
|
|
||||||
|
if (!onlyMargin) color("Orange") stroke(contour, closed=true);
|
||||||
|
marginPath = rect([marginW,marginH]);
|
||||||
|
color("Red") stroke(marginPath, closed=true);
|
||||||
|
};
|
||||||
|
//}
|
||||||
|
children();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( debugging ) {
|
||||||
|
//titleBlock("My First Project");
|
||||||
|
|
||||||
|
A4( onlyMargin = false,anchor=LEFT+FWD )
|
||||||
|
//align(align=TOP+LEFT+FWD,spin=[0, 0, 0],inside=true)
|
||||||
|
//attach(LEFT+FWD,/*RIGHT,inside=true*/)
|
||||||
|
//align(LEFT,inside=true)
|
||||||
|
align(FWD+RIGHT,inside=true)
|
||||||
|
titleBlock("Metal Desk",textSize=7,rect=[90,30],inset=2);
|
||||||
|
//cuboid([50,20,10],anchor=TOP);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user