Comments and fix

This commit is contained in:
Sébastien Dante Ursini 2025-02-17 22:34:47 -03:00
parent edf09a7cf5
commit cc8766b420
33 changed files with 1316 additions and 106 deletions

3
.gitignore vendored
View File

@ -2,6 +2,9 @@
.swp
docgen
docs/.source_hashes
## Customizers presets
quotes.json
titleBlock.json

9
.openscad_docsgen_rc Normal file
View File

@ -0,0 +1,9 @@
TargetProfile: githubwiki
GenerateDocs: Files, TOC, Index, Topics, CheatSheet, Sidebar
SidebarHeader:
## Indices
.
SidebarMiddle:
[Tutorials](Tutorials)
DefineHeader(BulletList): Side Effects
DefineHeader(Table;Headers=Anchor Name|Position): Extra Anchors

1
.openscad_mdimggen_rc Normal file
View File

@ -0,0 +1 @@
ColorScheme=BeforeDawn

16
.template.md Normal file
View File

@ -0,0 +1,16 @@
# {{project_name}} - {{project_version}}
{{overview}}
{{dependencies}}
{{usage}}
{{main}}
{{toc}}
{{topics}}
{{alpha_index}}

318
Readme.md
View File

@ -1,12 +1,320 @@
# Quote Library for Openscad
# Quotes - 0.9a
## Setup soft link
# Summary
Make a symbolic link to make the quotes library available as library
The quotes.scad library is a dimensioning and annotation utility for OpenSCAD, primarily used for adding labeled dimension lines to models. It is built on the BOSL2 (Bryan OpenSCAD Library v2) framework, utilizing functions to enhance technical drawing capabilities within OpenSCAD.
```bash
ln -s /Users/sursini/Documents/Design/OpenSCAD/Quotes /usr/local/share/openscad/libraries/Quotes
[Quotes API](docs/quotes.scad.md)
The titleBlock.scad library defines a title block system for technical drawings, providing a standardized layout for project metadata such as title, description, date, scale, and revision number. The script is built on BOSL2 (Bryan OpenSCAD Library v2) and Typography/typo.scad for text rendering.
[Title Block API](docs/titleBlock.scad.md)
## Project Dependencies
To use these libraries in your OpenSCAD project:
1. Ensure that you have the libraries (BOSL2, Typography, and titleBlock) in your OpenSCAD library path or project folder.
2. Use the include directive to bring in the necessary files. For example:
```c
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
```
## Installation
...
# LibFile: quotes.scad
To use, add the following lines to the beginning of your file:
include <BOSL2/std.scad>;
include <quotes.scad>;
## File Contents
- [`quote()`](#module-quote) – Draws a dimension line with optional text labeling the length.
- [`arrowed_line()`](#module-arrowed_line) – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](#module-ext_line) – Draws a straight extruded line between two points.
### Module: quote()
**Synopsis:** Draws a dimension line with optional text labeling the length.
**Topics:** [Dimensioning](Topics#dimensioning), [Annotation](Topics#annotation)
**Description:**
Creates a labeled dimension line with extension lines and an optional
length label. The dimension can be customized in terms of placement,
orientation, text formatting, and appearance.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`length` | The length of the dimension line.
`textSize` | Size of the text label [default: 60].
`offsetFromOrigin` | Distance of the dimension line from the reference [default: textSize].
`extendBeyondDimLines` | Length beyond the extension lines [default: textSize / 5].
`textOffset` | Offset of the text from the dimension line [default: textSize / 3].
`color` | Color of the dimension line and text [default: "Red"].
`placement` | Position relative to the model (TOP or BOTTOM) [default: TOP].
`strokeWidth` | Thickness of the lines [default: 1].
`font` | Font used for text [default: "Saira Stencil One"].
`orient` | Text orientation (TOP or BOTTOM) [default: TOP].
`anchor` | Text alignment reference (CENTER, LEFT, RIGHT) [default: CENTER].
`spin` | Spin.
**Example 1:** Simple quote
<img align="left" alt="quote() Example 1" src="docs/images/quotes/quote.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50);
<br clear="all" /><br/>
**Example 2:** Spin -90
<img align="left" alt="quote() Example 2" src="docs/images/quotes/quote_2.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50,spin=-90);
<br clear="all" /><br/>
**Example 3:** Orient FRONT
<img align="left" alt="quote() Example 3" src="docs/images/quotes/quote_3.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50,orient=FRONT);
<br clear="all" /><br/>
**Example 4:** Orient TOP
<img align="left" alt="quote() Example 4" src="docs/images/quotes/quote_4.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, orient=TOP);
<br clear="all" /><br/>
**Example 5:** offsetFromOrigin 20
<img align="left" alt="quote() Example 5" src="docs/images/quotes/quote_5.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, offsetFromOrigin=20);
<br clear="all" /><br/>
**Example 6:** extendBeyondDimLines 20
<img align="left" alt="quote() Example 6" src="docs/images/quotes/quote_6.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, extendBeyondDimLines=20);
<br clear="all" /><br/>
---
### Module: arrowed\_line()
**Synopsis:** Draws a straight line with arrowheads at both ends.
**Topics:** [Geometry](Topics#geometry), [Arrows](Topics#arrows), [Lines](Topics#lines)
**Description:**
Creates a linear extrusion representing a line with arrowheads at both ends.
The line thickness, length, and arrow size can be customized.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`point1` | [x, y] start point of the line.
`point2` | [x, y] end point of the line.
`width` | Thickness of the line [default: 0.1].
`endcap_width` | Width of the arrowhead at each end [default: 15].
**Example 1:**
<img align="left" alt="arrowed\_line() Example 1" src="docs/images/quotes/arrowed_line.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
arrowed_line([0,0], [50,50], width=0.5, endcap_width=5);
<br clear="all" /><br/>
---
### Module: ext\_line()
**Synopsis:** Draws a straight extruded line between two points.
**Topics:** [Geometry](Topics#geometry), [Lines](Topics#lines)
**Description:**
Creates a linear extrusion representing a straight line segment with a
specified width between two given points.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`point1` | [x, y] start point of the line.
`point2` | [x, y] end point of the line.
`width` | Thickness of the line [default: 0.1].
**Example 1:**
<img align="left" alt="ext\_line() Example 1" src="docs/images/quotes/ext_line.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
ext_line([0,0], [50,50], width=0.5);
<br clear="all" /><br/>
---
# Table of Contents
## List of Files
**Quotes:**
- [quotes.scad](#1-quotesscad) ([docs](quotes.scad))
Quotes,Dimensions
**TitleBlock:**
- [titleBlock.scad](#2-titleblockscad) ([docs](titleBlock.scad))
Title Block
## 1. [quotes.scad](quotes.scad)
Quotes,Dimensions
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
## 2. [titleBlock.scad](titleBlock.scad)
Title Block
- [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape) Const
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
# Topic Index
An index of topics, with related functions, modules, and constants.
**A**: [Annotation](#annotation), [Arrows](#arrows)
**D**: [Design](#design), [Dimensioning](#dimensioning), [Document Layout](#document-layout)
**G**: [Geometry](#geometry)
**L**: [Lines](#lines)
**M**: [Modularity](#modularity)
**T**: [Technical Drawings](#technical-drawings), [Templates](#templates)
### Annotation
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
### Arrows
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
### Design
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Dimensioning
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
### Document Layout
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Geometry
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
### Lines
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
### Modularity
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Technical Drawings
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
### Templates
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
# Alphabetical Index
An index of Functions, Modules, and Constants by name.
[A](#a) [E](#e) [P](#p) [Q](#q) [T](#t)
## A
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape) Const
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
## E
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
## P
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
## Q
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
## T
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.

6
config.ini Normal file
View File

@ -0,0 +1,6 @@
[project]
version=0.9a
name=Quotes
doc_folder=docs
main=quotes.scad

28
docs/AlphaIndex.md Normal file
View File

@ -0,0 +1,28 @@
# Alphabetical Index
An index of Functions, Modules, and Constants by name.
[A](#a) [E](#e) [P](#p) [Q](#q) [T](#t)
## A
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape) Const
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
## E
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
## P
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
## Q
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
## T
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.

12
docs/CheatSheet.md Normal file
View File

@ -0,0 +1,12 @@
# Quotes Cheat Sheet
## LibFile: titleBlock.scad
### Section:
Constants: [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape)
><code>[A4](titleBlock.scad#module-a4)(margin=15, landscape=false, onlyMargin=false);</code>
><code>[plan](titleBlock.scad#module-plan)("Project Alpha", title="Main Assembly", description="Assembly drawing", scale=2);</code>

12
docs/Dependencies.md Normal file
View File

@ -0,0 +1,12 @@
## Project Dependencies
To use these libraries in your OpenSCAD project:
1. Ensure that you have the libraries (BOSL2, Typography, and titleBlock) in your OpenSCAD library path or project folder.
2. Use the include directive to bring in the necessary files. For example:
```c
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
```

3
docs/Installation.md Normal file
View File

@ -0,0 +1,3 @@
## Installation
...

3
docs/Libraries.md Normal file
View File

@ -0,0 +1,3 @@
## Libraries
...

11
docs/Overview.md Normal file
View File

@ -0,0 +1,11 @@
# Summary
The quotes.scad library is a dimensioning and annotation utility for OpenSCAD, primarily used for adding labeled dimension lines to models. It is built on the BOSL2 (Bryan OpenSCAD Library v2) framework, utilizing functions to enhance technical drawing capabilities within OpenSCAD.
[Quotes API](docs/quotes.scad.md)
The titleBlock.scad library defines a title block system for technical drawings, providing a standardized layout for project metadata such as title, description, date, scale, and revision number. The script is built on BOSL2 (Bryan OpenSCAD Library v2) and Typography/typo.scad for text rendering.
[Title Block API](docs/titleBlock.scad.md)

31
docs/TOC.md Normal file
View File

@ -0,0 +1,31 @@
# Table of Contents
## List of Files
**Quotes:**
- [quotes.scad](#1-quotesscad) ([docs](quotes.scad))
Quotes,Dimensions
**TitleBlock:**
- [titleBlock.scad](#2-titleblockscad) ([docs](titleBlock.scad))
Title Block
## 1. [quotes.scad](quotes.scad)
Quotes,Dimensions
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
## 2. [titleBlock.scad](titleBlock.scad)
Title Block
- [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape) Const
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.

60
docs/Topics.md Normal file
View File

@ -0,0 +1,60 @@
# Topic Index
An index of topics, with related functions, modules, and constants.
**A**: [Annotation](#annotation), [Arrows](#arrows)
**D**: [Design](#design), [Dimensioning](#dimensioning), [Document Layout](#document-layout)
**G**: [Geometry](#geometry)
**L**: [Lines](#lines)
**M**: [Modularity](#modularity)
**T**: [Technical Drawings](#technical-drawings), [Templates](#templates)
### Annotation
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
### Arrows
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
### Design
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Dimensioning
- [`quote()`](quotes.scad#module-quote) Mod – Draws a dimension line with optional text labeling the length.
### Document Layout
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Geometry
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
### Lines
- [`arrowed_line()`](quotes.scad#module-arrowed_line) Mod – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](quotes.scad#module-ext_line) Mod – Draws a straight extruded line between two points.
### Modularity
- [`titleBlock()`](titleBlock.scad#module-titleblock) Mod – Generates a customizable title block layout for documents.
### Technical Drawings
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.
### Templates
- [`A4`](titleBlock.scad#module-a4) Mod – Generates an A4-sized boundary with configurable margins.
- [`plan`](titleBlock.scad#module-plan) Mod – Generates a structured technical drawing layout with a title block.

18
docs/_Sidebar.md Normal file
View File

@ -0,0 +1,18 @@
## Indices
[Table of Contents](TOC)
[Function Index](AlphaIndex)
[Topics Index](Topics)
[Cheat Sheet](CheatSheet)
[Tutorials](Tutorials)
## List of Files:
**Quotes:**
- [quotes.scad](quotes.scad)
**TitleBlock:**
- [titleBlock.scad](titleBlock.scad)

2
docs/_Usage.md Normal file
View File

@ -0,0 +1,2 @@
## Usage
...

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

169
docs/quotes.scad.md Normal file
View File

@ -0,0 +1,169 @@
# LibFile: quotes.scad
To use, add the following lines to the beginning of your file:
include <BOSL2/std.scad>;
include <quotes.scad>;
## File Contents
- [`quote()`](#module-quote) – Draws a dimension line with optional text labeling the length.
- [`arrowed_line()`](#module-arrowed_line) – Draws a straight line with arrowheads at both ends.
- [`ext_line()`](#module-ext_line) – Draws a straight extruded line between two points.
### Module: quote()
**Synopsis:** Draws a dimension line with optional text labeling the length.
**Topics:** [Dimensioning](Topics#dimensioning), [Annotation](Topics#annotation)
**Description:**
Creates a labeled dimension line with extension lines and an optional
length label. The dimension can be customized in terms of placement,
orientation, text formatting, and appearance.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`length` | The length of the dimension line.
`textSize` | Size of the text label [default: 60].
`offsetFromOrigin` | Distance of the dimension line from the reference [default: textSize].
`extendBeyondDimLines` | Length beyond the extension lines [default: textSize / 5].
`textOffset` | Offset of the text from the dimension line [default: textSize / 3].
`color` | Color of the dimension line and text [default: "Red"].
`placement` | Position relative to the model (TOP or BOTTOM) [default: TOP].
`strokeWidth` | Thickness of the lines [default: 1].
`font` | Font used for text [default: "Saira Stencil One"].
`orient` | Text orientation (TOP or BOTTOM) [default: TOP].
`anchor` | Text alignment reference (CENTER, LEFT, RIGHT) [default: CENTER].
`spin` | Spin.
**Example 1:** Simple quote
<img align="left" alt="quote() Example 1" src="images/quotes/quote.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50);
<br clear="all" /><br/>
**Example 2:** Spin -90
<img align="left" alt="quote() Example 2" src="images/quotes/quote_2.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50,spin=-90);
<br clear="all" /><br/>
**Example 3:** Orient FRONT
<img align="left" alt="quote() Example 3" src="images/quotes/quote_3.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, textSize=50,orient=FRONT);
<br clear="all" /><br/>
**Example 4:** Orient TOP
<img align="left" alt="quote() Example 4" src="images/quotes/quote_4.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, orient=TOP);
<br clear="all" /><br/>
**Example 5:** offsetFromOrigin 20
<img align="left" alt="quote() Example 5" src="images/quotes/quote_5.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, offsetFromOrigin=20);
<br clear="all" /><br/>
**Example 6:** extendBeyondDimLines 20
<img align="left" alt="quote() Example 6" src="images/quotes/quote_6.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
quote(length=100, extendBeyondDimLines=20);
<br clear="all" /><br/>
---
### Module: arrowed\_line()
**Synopsis:** Draws a straight line with arrowheads at both ends.
**Topics:** [Geometry](Topics#geometry), [Arrows](Topics#arrows), [Lines](Topics#lines)
**Description:**
Creates a linear extrusion representing a line with arrowheads at both ends.
The line thickness, length, and arrow size can be customized.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`point1` | [x, y] start point of the line.
`point2` | [x, y] end point of the line.
`width` | Thickness of the line [default: 0.1].
`endcap_width` | Width of the arrowhead at each end [default: 15].
**Example 1:**
<img align="left" alt="arrowed\_line() Example 1" src="images/quotes/arrowed_line.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
arrowed_line([0,0], [50,50], width=0.5, endcap_width=5);
<br clear="all" /><br/>
---
### Module: ext\_line()
**Synopsis:** Draws a straight extruded line between two points.
**Topics:** [Geometry](Topics#geometry), [Lines](Topics#lines)
**Description:**
Creates a linear extrusion representing a straight line segment with a
specified width between two given points.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`point1` | [x, y] start point of the line.
`point2` | [x, y] end point of the line.
`width` | Thickness of the line [default: 0.1].
**Example 1:**
<img align="left" alt="ext\_line() Example 1" src="images/quotes/ext_line.png" width="320" height="240">
include <BOSL2/std.scad>;
include <quotes.scad>;
ext_line([0,0], [50,50], width=0.5);
<br clear="all" /><br/>
---

165
docs/titleBlock.scad.md Normal file
View File

@ -0,0 +1,165 @@
# LibFile: titleBlock.scad
To use, add the following lines to the beginning of your file:
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
## File Contents
- [`A4_LANDSCAPE`](#constant-a4_landscape)
- [`titleBlock()`](#module-titleblock) – Generates a customizable title block layout for documents.
- [`A4`](#module-a4) – Generates an A4-sized boundary with configurable margins.
- [`plan`](#module-plan) – Generates a structured technical drawing layout with a title block.
### Constant: A4\_LANDSCAPE
**Description:**
A4 Page dimensions
---
### Module: titleBlock()
**Synopsis:** Generates a customizable title block layout for documents.
**Topics:** [Document Layout](Topics#document-layout), [Design](Topics#design), [Modularity](Topics#modularity)
**Description:**
This module creates a title block that includes a project title, description,
scale, revision, date, and other metadata. It supports full customization of
text size, positioning, and color. The title block is fully parametric,
allowing for flexible layout adjustments.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`project` | The project name or title to be displayed. [default: undef]
`title` | The title text to display. [default: undef]
`description` | A description of the project or work. [default: ""]
`textSize` | The size of the text to be used in the title block. [default: 6]
`date` | The date associated with the project. [default: "2025-01-01"]
`scale` | The scale of the project (e.g., 1:10). [default: 1]
`revision` | The project revision or version. [default: "1a"]
`rect` | The width and height of the title block. [default: [90,30]]
`inset` | The inset (margin) around the title block content. [default: 2]
`anchor` | The anchor position for the title block. [default: CENTER]
`spin` | The rotation angle of the title block. [default: 0]
`orient` | The orientation of the title block. [default: UP]
`color` | The color of the title block text. [default: "Black"]
`strokeWidth` | The width of the title block's stroke. [default: 0.5]
`page` | The paper size (A4, etc.). [default: "A4"]
`landscape` | Whether the title block is in landscape orientation. [default: true]
**Example 1:** Title Block
<img align="left" alt="titleBlock() Example 1" src="images/titleBlock/titleblock.png" width="640" height="480">
<br clear="all" />
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
titleBlock(
project = "X-Drone",
title = "Engineering Design",
description = "This project focuses on designing a new type of drone for urban delivery services",
date = "2025-02-17",
revision = "A1",
scale = 20
);
---
### Module: A4
**Synopsis:** Generates an A4-sized boundary with configurable margins.
**Topics:** [Templates](Topics#templates), [Technical Drawings](Topics#technical-drawings)
**Usage:**
- A4(margin=15, landscape=false, onlyMargin=false);
**Description:**
This module defines an A4-sized boundary for technical drawings, with configurable
margins. It provides an optional outer frame and allows child objects to be placed
within the margin area. The module can be used for layout planning in OpenSCAD.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`margin` | Margin size (default: 10).
`landscape` | Boolean flag to switch between landscape and portrait mode (default: true).
`onlyMargin` | If true, renders only the margin area; otherwise, includes the full frame (default: true).
`anchor` | Anchor position for alignment (default: CENTER).
`spin` | Rotation angle in degrees (default: 0).
`orient` | Orientation of the bounding box (default: UP).
`scale` | Scale factor (default: 1).
`strokeWidth` | Stroke width for the drawing boundary (default: 0.2).
**Example 1:** A4 with border and margin
<img align="left" alt="A4 Example 1" src="images/titleBlock/a4.png" width="640" height="480">
<br clear="all" />
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
A4( onlyMargin = false );
**Example 2:** A4 without border
<img align="left" alt="A4 Example 2" src="images/titleBlock/a4_2.png" width="640" height="480">
<br clear="all" />
include <BOSL2/std.scad>;
include <Typography/typo.scad>;
include <titleBlock.scad>;
A4( onlyMargin = true );
---
### Module: plan
**Synopsis:** Generates a structured technical drawing layout with a title block.
**Topics:** [Templates](Topics#templates), [Technical Drawings](Topics#technical-drawings)
**Usage:**
- plan("Project Alpha", title="Main Assembly", description="Assembly drawing", scale=2);
**Description:**
This module creates a structured layout for technical drawings. It includes a title block
positioned within an A4-sized frame, allowing child objects to be placed within the defined
margins. The layout is configurable to support different project details and orientations.
**Arguments:**
<abbr title="These args can be used by position or by name.">By&nbsp;Position</abbr> | What it does
-------------------- | ------------
`project` | Project name (required).
`title` | Title of the drawing (default: undef).
`description` | Short description of the drawing (default: "").
`textSize` | Size of the text in the title block (default: 6).
`date` | Date to be displayed in the title block (default: "2025-01-01").
`scale` | Scale factor for the drawing (default: 1).
`revision` | Revision identifier (default: "1a").
`page` | Page size identifier (default: "A4").
`margin` | Margin size around the drawing area (default: 10).
`orient` | Orientation of the drawing (default: UP).
---

View File

@ -1,15 +1,12 @@
include <titleBlock.scad>
include <quotes.scad>
plan(
"Title Block",
title="Sub title",
description="Description",
) {
plan (
"Title Block",
title = "Sub title",
description = "Description"
)
{
scaling = 10;
@ -18,24 +15,13 @@ plan(
w = 800;
h = 600;
//projection()
projection()
color ("Gray") cube([w,h,1],anchor=CENTER+TOP) {
show_anchors();
align(BACK)
quote(w/*,anchor=LEFT*/){
show_anchors();
}
;
//right (800)
//attach(RIGHT,UP)
color("black") up(2)
align( RIGHT )
//quote(h/*,anchor=LEFT*/,color="Black")
quote(h,spin=-90) show_anchors()
;
align(BACK) quote(w);
color("black")
align( RIGHT ) quote(h,spin=-90,font="Roboto Condensed");
}
}

View File

@ -2,6 +2,7 @@
// LibFile: quotes.scad
// Includes:
// include <BOSL2/std.scad>;
// include <quotes.scad>;
// FileGroup: Quotes
// FileSummary: Quotes,Dimensions
//////////////////////////////////////////////////////////////////////
@ -26,29 +27,39 @@ quotes_debugging = false;
// offsetFromOrigin = Distance of the dimension line from the reference [default: textSize].
// extendBeyondDimLines = Length beyond the extension lines [default: textSize / 5].
// textOffset = Offset of the text from the dimension line [default: textSize / 3].
// direction = Direction of the dimension (RIGHT, LEFT, UP, DOWN) [default: RIGHT].
// color = Color of the dimension line and text [default: "Red"].
// placement = Position relative to the model (TOP or BOTTOM) [default: TOP].
// strokeWidth = Thickness of the lines [default: 1].
// font = Font used for text [default: "Saira Stencil One"].
// orient = Text orientation (TOP or BOTTOM) [default: TOP].
// anchor = Text alignment reference (CENTER, LEFT, RIGHT) [default: CENTER].
// Example:
// quote(length=100, textSize=50, placement=TOP, direction=RIGHT);
// spin = Spin.
// Example(3D,ColorScheme=Nature): Simple quote
// quote(length=100, textSize=50);
// Example(3D,ColorScheme=Nature): Spin -90
// quote(length=100, textSize=50,spin=-90);
// Example(3D,ColorScheme=Nature): Orient FRONT
// quote(length=100, textSize=50,orient=FRONT);
// Example(3D,ColorScheme=Nature): Orient TOP
// quote(length=100, orient=TOP);
// Example(3D,ColorScheme=Nature): offsetFromOrigin 20
// quote(length=100, offsetFromOrigin=20);
// Example(3D,ColorScheme=Nature): extendBeyondDimLines 20
// quote(length=100, extendBeyondDimLines=20);
module quote(
length,
textSize = 60,
offsetFromOrigin = undef,
extendBeyondDimLines = undef,
textOffset = undef,
//direction = RIGHT,
color = "Red",
placement = TOP,
strokeWidth = 1,
font = "Saira Stencil One",
orient = TOP,
anchor = CENTER,
spin = 0
textSize = 40,
offsetFromOrigin = undef,
extendBeyondDimLines = undef,
textOffset = undef,
color = "Red",
placement = TOP,
strokeWidth = 0.2,
font = "Roboto Condensed", //"Saira Stencil One",
orient = TOP,
anchor = CENTER,
spin = 0
) {
// Default values if undefined
@ -65,33 +76,20 @@ module quote(
attachable(anchor, spin, orient, size=size) {
// Compute rotation angle
/*
angle =
direction == RIGHT ? 0 :
direction == LEFT ? 180 :
direction == FRONT ? -90 :
direction == BACK ? +90 : 0;
*/
// Compute shift based on anchor point
shift =
anchor == RIGHT ? length/2 :
anchor == LEFT ? -length/2 : 0;
// Adjust placement offset
actualOffset = (placement == BOTTOM) ? -_offsetFromOrigin : _offsetFromOrigin;
extOffset = (placement == BOTTOM) ? -_extendBeyondDimLines : _extendBeyondDimLines;
// Draw the dimension
recolor(color) {
//zrot(angle)
left(shift) {
arrowed_line([-length / 2, actualOffset, 0], [length / 2, actualOffset, 0]); // Parallel dimension line
ext_line([-length / 2, 0, 0], [-length / 2, actualOffset + extOffset, 0]); // Left extension line
ext_line([length / 2, 0, 0], [length / 2, actualOffset + extOffset, 0]); // Right extension line
arrowed_line([-length / 2, actualOffset, 0], [length / 2, actualOffset, 0],width=strokeWidth); // Parallel dimension line
ext_line([-length / 2, 0, 0], [-length / 2, actualOffset + extOffset, 0],width=strokeWidth); // Left extension line
ext_line([length / 2, 0, 0], [length / 2, actualOffset + extOffset, 0],width=strokeWidth); // Right extension line
back(actualOffset + _textOffset)
linear_extrude(0.1)
text(str(length), size = textSize, font = font, halign = "center"); // Label
@ -114,7 +112,7 @@ module quote(
// point2 = [x, y] end point of the line.
// width = Thickness of the line [default: 0.1].
// endcap_width = Width of the arrowhead at each end [default: 15].
// Example:
// Example(3D,ColorScheme=Nature):
// arrowed_line([0,0], [50,50], width=0.5, endcap_width=5);
module arrowed_line( p1, p2 , width=0.5, endcap_width = 15) {
dir = p2 - p1;
@ -151,7 +149,7 @@ module arrowed_line( p1, p2 , width=0.5, endcap_width = 15) {
// point1 = [x, y] start point of the line.
// point2 = [x, y] end point of the line.
// width = Thickness of the line [default: 0.1].
// Example:
// Example(3D,ColorScheme=Nature):
// ext_line([0,0], [50,50], width=0.5);
module ext_line(p1, p2, width = 0.5) {
dir = p2 - p1;
@ -168,20 +166,14 @@ module ext_line(p1, p2, width = 0.5) {
if ( quotes_debugging ) {
//projection()
quote(
500,
textSize=80,
//direction=RIGHT,
//placement=BOTTOM,
strokeWidth=2,
orient=UP,
spin=-90,
anchor=CENTER
);
left (600) quote(
500,
//direction=UP
);
left (600) quote(500);
}

212
run Executable file
View File

@ -0,0 +1,212 @@
#!/bin/bash
# Function to install docgen
install_docgen() {
echo "Creating virtual environment..."
python3 -m venv docgen
source docgen/bin/activate
echo "Installing openscad_docsgen..."
pip install openscad_docsgen
echo "Installation completed."
}
# Function to uninstall (deactivate the virtual environment)
uninstall_docgen() {
echo "Deactivating virtual environment..."
deactivate
echo "Virtual environment deactivated."
}
# INI Parser
parse_ini() {
# Check if file exists and is readable
local ini_file="$1"
if [[ ! -f "$ini_file" ]] || [[ ! -r "$ini_file" ]]; then
echo "Error: Cannot read file $ini_file" >&2
return 1
fi # Changed this brace from } to fi
# Initialize section variable
local current_section=""
# Read the file line by line
while IFS= read -r line || [[ -n "$line" ]]; do
# Trim whitespace
line="${line##*( )}"
line="${line%%*( )}"
# Skip empty lines and comments
[[ -z "$line" ]] || [[ "$line" == \#* ]] && continue
# Check if it's a section
if [[ "$line" =~ ^\[(.*)\]$ ]]; then
current_section="${BASH_REMATCH[1]}"
continue
fi
# Parse key-value pairs
if [[ "$line" =~ ^([^=]+)=(.*)$ ]]; then
local key="${BASH_REMATCH[1]}"
local value="${BASH_REMATCH[2]}"
# Trim whitespace from key and value
key="${key##*( )}"
key="${key%%*( )}"
value="${value##*( )}"
value="${value%%*( )}"
# Remove quotes if present
value="${value#\"}"
value="${value%\"}"
value="${value#\'}"
value="${value%\'}"
# Create variable name
local var_name
if [[ -n "$current_section" ]]; then
# If in a section, prefix variable with section name
var_name="${current_section}_${key}"
else
var_name="$key"
fi
# Make variable name safe for bash
var_name=$(echo "$var_name" | sed 's/[^a-zA-Z0-9_]/_/g')
# Export the variable
#declare -g "$var_name=$value"
eval "export $var_name='$value'"
fi
done < "$ini_file"
}
# Parse config.ini
parse_ini config.ini
# Debug: Print all variables in the environment
echo "Environment variables after parsing:"
printenv | grep -E "project_name|template|doc_folder|version"
compose_template() {
# Define variables
#project_name="Shelving Unit"
template=".template.md"
#doc_folder="docs"
doc_folder=$project_doc_folder
# Create temp files
tmp_overview=$(mktemp)
tmp_dependencies=$(mktemp)
tmp_usage=$(mktemp)
tmp_installation=$(mktemp)
tmp_toc=$(mktemp)
tmp_main=$(mktemp)
tmp_table_of_contents=$(mktemp)
tmp_topics=$(mktemp)
tmp_alpha_index=$(mktemp)
tmp_sidebar=$(mktemp)
# Read content into temp files
process_md "Overview" "$tmp_overview"
process_md "Dependencies" "$tmp_dependencies"
process_md "Usage" "$tmp_usage"
process_md "Installation" "$tmp_usage"
# process_md "$project_main" "$tmp_main"
# cat "$doc_folder/shelf.scad.md" > "$tmp_main"
# Replace image links in main
# sed -i 's|images/|docs/images/|g' "$tmp_main"
if [ -f "$doc_folder/${project_main}.md" ]; then
cat "$doc_folder/${project_main}.md" | sed 's|images/|docs/images/|g' > "$tmp_main"
fi
process_md "TOC" "$tmp_toc"
process_md "_Sidebar" "$tmp_table_of_contents"
process_md "Topics" "$tmp_topics"
process_md "AlphaIndex" "$tmp_alpha_index"
process_md "_Sidebar" "$tmp_sidebar"
# Use sed with file reads
sed -e "s|{{project_name}}|$project_name|g" \
-e "s|{{project_version}}|$project_version|g" \
-e "/{{overview}}/r $tmp_overview" -e "/{{overview}}/d" \
-e "/{{dependencies}}/r $tmp_dependencies" -e "/{{dependencies}}/d" \
-e "/{{usage}}/r $tmp_usage" -e "/{{usage}}/d" \
-e "/{{installation}}/r $tmp_usage" -e "/{{installation}}/d" \
-e "/{{main}}/r $tmp_main" -e "/{{main}}/d" \
-e "/{{toc}}/r $tmp_toc" -e "/{{toc}}/d" \
-e "/{{table_of_contents}}/r $tmp_table_of_contents" -e "/{{table_of_contents}}/d" \
-e "/{{topics}}/r $tmp_topics" -e "/{{topics}}/d" \
-e "/{{alpha_index}}/r $tmp_alpha_index" -e "/{{alpha_index}}/d" \
-e "/{{sidebar}}/r $tmp_sidebar" -e "/{{sidebar}}/d" \
"$template" > README.md
# Clean up temp files
rm -f "$tmp_overview" "$tmp_dependencies" "$tmp_usage" "$tmp_toc" "$tmp_table_of_contents" "$tmp_topics" "$tmp_alpha_index" "$tmp_sidebar"
echo "README.md has been generated."
}
# Function to run openscad-docsgen with your specified options
run_docsgen() {
# Check if we are in the virtual environment
if [ -z "$VIRTUAL_ENV" ] || [ ! "$(basename "$VIRTUAL_ENV")" == "docgen" ]; then
echo "Activating docgen virtual environment..."
source docgen/bin/activate || { echo "Failed to activate virtual environment. Make sure 'docgen' exists."; return 1; }
fi
echo "Running openscad-docsgen..."
#openscad-docsgen -m -I -P "Metalib" -f -p wiki -i -t -m -s
openscad-docsgen -f -P "$project_name"
echo "Documentation generation completed."
compose_template
echo "Documentation composition completed"
}
process_md() {
local src_file="$doc_folder/$1.md"
local dest_file="$2"
if [ -f "$src_file" ]; then
if [ "$1" == "$project_main" ]; then
sed 's|images/|docs/images/|g' "$src_file" > "$dest_file"
else
cat "$src_file" > "$dest_file"
fi
fi
}
# Main script logic
echo "OpenSCAD DocsGen Script"
echo "----------------------"
echo "1. Doc Generation"
echo "2. Install docgen"
echo "3. Uninstall docgen"
echo "q. Exit"
while true; do
read -p "Choose an option (1/2/3/q): " choice
case $choice in
1)
run_docsgen
;;
2)
install_docgen
;;
3)
uninstall_docgen
;;
q)
echo "Exiting script. Goodbye!"
exit 0
;;
*)
echo "Invalid option. Please try again."
;;
esac
done

View File

@ -1,23 +1,76 @@
//////////////////////////////////////////////////////////////////////
// LibFile: titleBlock.scad
// Includes:
// include <BOSL2/std.scad>;
// include <Typography/typo.scad>;
// include <titleBlock.scad>;
// FileGroup: TitleBlock
// FileSummary: Title Block
//////////////////////////////////////////////////////////////////////
include <BOSL2/std.scad>
include <Typography/typo.scad>
title_block_debugging = false;
/* [Hidden] */
// Constant: A4_LANDSCAPE
// Description: A4 Page dimensions
A4_LANDSCAPE= [297,210];
title_block_debugging = false;
experimental = true;
// Module: titleBlock()
//
// Synopsis: Generates a customizable title block layout for documents.
// Topics: Document Layout, Design, Modularity
// Description:
// This module creates a title block that includes a project title, description,
// scale, revision, date, and other metadata. It supports full customization of
// text size, positioning, and color. The title block is fully parametric,
// allowing for flexible layout adjustments.
// Arguments:
// project = The project name or title to be displayed. [default: undef]
// title = The title text to display. [default: undef]
// description= A description of the project or work. [default: ""]
// textSize = The size of the text to be used in the title block. [default: 6]
// date = The date associated with the project. [default: "2025-01-01"]
// scale = The scale of the project (e.g., 1:10). [default: 1]
// revision = The project revision or version. [default: "1a"]
// rect = The width and height of the title block. [default: [90,30]]
// inset = The inset (margin) around the title block content. [default: 2]
// anchor = The anchor position for the title block. [default: CENTER]
// spin = The rotation angle of the title block. [default: 0]
// orient = The orientation of the title block. [default: UP]
// color = The color of the title block text. [default: "Black"]
// strokeWidth= The width of the title block's stroke. [default: 0.5]
// page = The paper size (A4, etc.). [default: "A4"]
// landscape = Whether the title block is in landscape orientation. [default: true]
// DefineHeader:Returns:
// A parametric title block layout with project and metadata information.
// Example(3D,Big,ColorScheme=Nature): Title Block
// titleBlock(
// project = "X-Drone",
// title = "Engineering Design",
// description = "This project focuses on designing a new type of drone for urban delivery services",
// date = "2025-02-17",
// revision = "A1",
// scale = 20
// );
//
//
//
//
module titleBlock(
project,
title = undef,
description = "",
textSize=6,
textSize = 6,
date="2025-01-01",
scale=1,
revision="1a",
rect=[90,30],
inset=10,
inset=2,
anchor=CENTER,
spin=0,
orient=UP,
@ -30,54 +83,78 @@ module titleBlock(
) {
w = rect[0];
h = rect[1];
interline = 7;
_inset = inset> 0 ? inset : h/20;
//echo ("rect",rect);
//echo ("h",h);
//l1 = h/2 - _inset;
l1 = h/2 - 1.5* textSize - _inset;
//echo ("l1",l1);
interline = 0;
//path = rect([w,h], chamfer=0 /*, anchor=FRONT*/);
attachable(anchor,spin,orient, size=[w,h,50]) {
projection( cut = false ) recolor(color) union() {
attachable(anchor,spin,orient=TOP, size=[w,h,1]) {
//projection( cut = false )
projection() union() recolor(color) {
// ************ Frame ***************
rect_tube(size=[w,h], wall=0.5, h=0.1);
l1 = h/2 - _inset;
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");
linear_extrude(0.1,convexity = 10)
text(project, size=textSize,halign="left",valign="baseline",anchor=BOTTOM+LEFT,font="Saira Stencil One");
// ************ Scale ***************
translate([w/2-_inset, l1])
linear_extrude(0.1)
text(str("Scale: 1/",scale), size=textSize*2/5,halign="right",anchor=TOP);
text(str("Scale: 1/",scale), size=textSize*2/5,halign="right",valign="baseline",anchor=BOTTOM);
// ************ 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");
translate([-w /2+_inset, l1 - 2* _inset ])
linear_extrude(0.1)
//text( title, size=textSize*2/4,halign="left",anchor=TOP,font="Arial Black");
smartText(
title,
size = textSize*2/4,
halign = "left",
font = "Arial Black",// "Courier New:style=Italic"
style = "Regular",
max_width = 5,
interline = 4
);
// ************ Description ***************
if ( description ) {
translate([ -8, l2 - _inset/2 ])
//translate([ -8, l2 - _inset/2 ])
translate([ -8, l1 - _inset*2 ])
linear_extrude(0.1)
smartText(
description,
size=textSize*1/4,
halign="left",
font="Arial",
style="italic",
max_width = 51
size = textSize*1/4,
halign = "left",
font = "Courier New",// "Courier New:style=Italic"
style = "Italic",
max_width = 51,
//interline = -5
);
}
// ************ HL ***************
h1 = h/2-2*_inset - interline;
translate([-w/2+_inset,h1,0]) cube([w-2*_inset,0.1,0.1]);
translate([-w/2+_inset,l1,0])
cube([w-2*_inset,0.1,0.1]);
// ************ Vertical sep ***************
translate([10,interline-1*_inset/2,0]) cube([0.1,interline,0.1]);
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]) {
translate([w/2-_inset-18, -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");
}
@ -86,7 +163,40 @@ module titleBlock(
};
}
// Module: A4
//
// Synopsis: Generates an A4-sized boundary with configurable margins.
// Topics: Templates, Technical Drawings
// Description:
// This module defines an A4-sized boundary for technical drawings, with configurable
// margins. It provides an optional outer frame and allows child objects to be placed
// within the margin area. The module can be used for layout planning in OpenSCAD.
//
// Arguments:
// margin = Margin size (default: 10).
// landscape = Boolean flag to switch between landscape and portrait mode (default: true).
// onlyMargin = If true, renders only the margin area; otherwise, includes the full frame (default: true).
// anchor = Anchor position for alignment (default: CENTER).
// spin = Rotation angle in degrees (default: 0).
// orient = Orientation of the bounding box (default: UP).
// scale = Scale factor (default: 1).
// strokeWidth = Stroke width for the drawing boundary (default: 0.2).
//
// Usage:
// A4(margin=15, landscape=false, onlyMargin=false);
//
// DefineHeader:Notes:
// - The A4 paper dimensions are standardized at 210mm x 297mm (portrait mode).
// - If `landscape` is true, the width and height are swapped.
//
// DefineHeader:Returns:
// - A 2D boundary representation of an A4 page with an optional margin outline.
//
// Example(3D,Big,ColorScheme=Nature): A4 with border and margin
// A4( onlyMargin = false );
// Example(3D,Big,ColorScheme=Nature): A4 without border
// A4( onlyMargin = true );
//
module A4( margin = 10, landscape = true, onlyMargin = true, anchor=CENTER, spin=0, orient=UP, scale=1, strokeWidth=0.2 ){
w = A4_LANDSCAPE[0];
h = A4_LANDSCAPE[1];
@ -94,17 +204,47 @@ module A4( margin = 10, landscape = true, onlyMargin = true, anchor=CENTER, spin
marginH = h-2*margin;
attachable(anchor,spin, orient, size=[marginW,marginH,50]) {
projection( cut = false ) union(){
projection( cut = false )
union(){
if (!onlyMargin)
color("Orange")
rect_tube(size=[w,h], wall=0.1, h=0.1);
color("Red")
rect_tube(size=[marginW,marginH], wall=0.1, h=0.1);
};
children();
};
children();
}
}
// Module: plan
//
// Synopsis: Generates a structured technical drawing layout with a title block.
// Topics: Templates, Technical Drawings
// Description:
// This module creates a structured layout for technical drawings. It includes a title block
// positioned within an A4-sized frame, allowing child objects to be placed within the defined
// margins. The layout is configurable to support different project details and orientations.
//
// Arguments:
// project = Project name (required).
// title = Title of the drawing (default: undef).
// description = Short description of the drawing (default: "").
// textSize = Size of the text in the title block (default: 6).
// date = Date to be displayed in the title block (default: "2025-01-01").
// scale = Scale factor for the drawing (default: 1).
// revision = Revision identifier (default: "1a").
// page = Page size identifier (default: "A4").
// margin = Margin size around the drawing area (default: 10).
// orient = Orientation of the drawing (default: UP).
//
// Usage:
// plan("Project Alpha", title="Main Assembly", description="Assembly drawing", scale=2);
//
// DefineHeader:Notes:
// - This module uses `A4()` for the page layout and `titleBlock()` for the title block.
// - The `align()` function ensures proper positioning of the title block.
// - The `children()` function allows for additional drawing elements to be included.
module plan(
project,
title = undef,
@ -113,14 +253,16 @@ module plan(
date = "2025-01-01",
scale = 1,
revision = "1a",
page = "A4"
page = "A4",
margin = 10,
orient = UP
)
{
A4( onlyMargin = false, anchor=LEFT+FWD, scale=2 ) {
A4( onlyMargin = false, anchor=LEFT+FWD, scale=2,orient=orient /*, orient*/ ) {
//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 ) {
align( FWD+RIGHT,inside=true ) {
titleBlock(
project,
title = title,
@ -131,9 +273,14 @@ module plan(
);
};
align(BACK+LEFT,inside=true) {
children();
}
//align(BACK+LEFT /*,inside=true*/)
//if (page == "A4")
//translate([-A4_LANDSCAPE[0]/2+margin,+A4_LANDSCAPE[1]/2-margin,0])
// children();
//else
children();
}
}
@ -143,14 +290,30 @@ 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(
if (true) plan(
"Title Block",
title="Sub title",
title="Engineering Design",
description=lorem,
) {
//projection( cut = false ) cube([100,100,100]);
}
projection( cut = false ) cube([5,5,5],anchor=BACK+LEFT);
}
//A4()
//show_anchors()
// ;
if (false) titleBlock(
project = "Project",
title = "Engineering Design",
description = lorem,
//rect = [90,30],
)
//show_anchors()
;
}