diff --git a/.gitignore b/.gitignore index c187832..739ea5f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .swp +docgen +docs/.source_hashes + ## Customizers presets quotes.json titleBlock.json diff --git a/.openscad_docsgen_rc b/.openscad_docsgen_rc new file mode 100644 index 0000000..e929fa7 --- /dev/null +++ b/.openscad_docsgen_rc @@ -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 diff --git a/.openscad_mdimggen_rc b/.openscad_mdimggen_rc new file mode 100644 index 0000000..6cb875e --- /dev/null +++ b/.openscad_mdimggen_rc @@ -0,0 +1 @@ +ColorScheme=BeforeDawn diff --git a/.template.md b/.template.md new file mode 100644 index 0000000..0d0f773 --- /dev/null +++ b/.template.md @@ -0,0 +1,16 @@ +# {{project_name}} - {{project_version}} + +{{overview}} + +{{dependencies}} + +{{usage}} + +{{main}} + +{{toc}} + +{{topics}} + +{{alpha_index}} + diff --git a/Readme.md b/Readme.md index 9e2d6f2..d81a59e 100644 --- a/Readme.md +++ b/Readme.md @@ -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 ; +include ; +include ; ``` +## Installation + +... +# LibFile: quotes.scad + + +To use, add the following lines to the beginning of your file: + + include ; + include ; + +## 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:** + +By Position | 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 + +quote() Example 1 + + include ; + include ; + quote(length=100, textSize=50); + +

+ +**Example 2:** Spin -90 + +quote() Example 2 + + include ; + include ; + quote(length=100, textSize=50,spin=-90); + +

+ +**Example 3:** Orient FRONT + +quote() Example 3 + + include ; + include ; + quote(length=100, textSize=50,orient=FRONT); + +

+ +**Example 4:** Orient TOP + +quote() Example 4 + + include ; + include ; + quote(length=100, orient=TOP); + +

+ +**Example 5:** offsetFromOrigin 20 + +quote() Example 5 + + include ; + include ; + quote(length=100, offsetFromOrigin=20); + +

+ +**Example 6:** extendBeyondDimLines 20 + +quote() Example 6 + + include ; + include ; + quote(length=100, extendBeyondDimLines=20); + +

+ +--- + +### 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:** + +By Position | 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:** + +arrowed\_line() Example 1 + + include ; + include ; + arrowed_line([0,0], [50,50], width=0.5, endcap_width=5); + +

+ +--- + +### 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:** + +By Position | 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:** + +ext\_line() Example 1 + + include ; + include ; + ext_line([0,0], [50,50], width=0.5); + +

+ +--- + + +# 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. diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..dcb4a83 --- /dev/null +++ b/config.ini @@ -0,0 +1,6 @@ +[project] +version=0.9a +name=Quotes +doc_folder=docs +main=quotes.scad + diff --git a/docs/AlphaIndex.md b/docs/AlphaIndex.md new file mode 100644 index 0000000..e106699 --- /dev/null +++ b/docs/AlphaIndex.md @@ -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. + diff --git a/docs/CheatSheet.md b/docs/CheatSheet.md new file mode 100644 index 0000000..affd102 --- /dev/null +++ b/docs/CheatSheet.md @@ -0,0 +1,12 @@ +# Quotes Cheat Sheet + +## LibFile: titleBlock.scad + +### Section: + +Constants: [`A4_LANDSCAPE`](titleBlock.scad#constant-a4_landscape) +>[A4](titleBlock.scad#module-a4)(margin=15, landscape=false, onlyMargin=false); + +>[plan](titleBlock.scad#module-plan)("Project Alpha", title="Main Assembly", description="Assembly drawing", scale=2); + + diff --git a/docs/Dependencies.md b/docs/Dependencies.md new file mode 100644 index 0000000..9190e56 --- /dev/null +++ b/docs/Dependencies.md @@ -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 ; +include ; +include ; +``` \ No newline at end of file diff --git a/docs/Installation.md b/docs/Installation.md new file mode 100644 index 0000000..bf7ce31 --- /dev/null +++ b/docs/Installation.md @@ -0,0 +1,3 @@ +## Installation + +... \ No newline at end of file diff --git a/docs/Libraries.md b/docs/Libraries.md new file mode 100644 index 0000000..43619e3 --- /dev/null +++ b/docs/Libraries.md @@ -0,0 +1,3 @@ +## Libraries + +... \ No newline at end of file diff --git a/docs/Overview.md b/docs/Overview.md new file mode 100644 index 0000000..b4fe67c --- /dev/null +++ b/docs/Overview.md @@ -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) \ No newline at end of file diff --git a/docs/TOC.md b/docs/TOC.md new file mode 100644 index 0000000..febe74a --- /dev/null +++ b/docs/TOC.md @@ -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. + + diff --git a/docs/Topics.md b/docs/Topics.md new file mode 100644 index 0000000..0ebdb93 --- /dev/null +++ b/docs/Topics.md @@ -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. + diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md new file mode 100644 index 0000000..270738d --- /dev/null +++ b/docs/_Sidebar.md @@ -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) + diff --git a/docs/_Usage.md b/docs/_Usage.md new file mode 100644 index 0000000..b57494e --- /dev/null +++ b/docs/_Usage.md @@ -0,0 +1,2 @@ +## Usage +... \ No newline at end of file diff --git a/docs/images/quotes/arrowed_line.png b/docs/images/quotes/arrowed_line.png new file mode 100644 index 0000000..33d9600 Binary files /dev/null and b/docs/images/quotes/arrowed_line.png differ diff --git a/docs/images/quotes/ext_line.png b/docs/images/quotes/ext_line.png new file mode 100644 index 0000000..33c9966 Binary files /dev/null and b/docs/images/quotes/ext_line.png differ diff --git a/docs/images/quotes/quote.png b/docs/images/quotes/quote.png new file mode 100644 index 0000000..89323b4 Binary files /dev/null and b/docs/images/quotes/quote.png differ diff --git a/docs/images/quotes/quote_2.png b/docs/images/quotes/quote_2.png new file mode 100644 index 0000000..b0e14a7 Binary files /dev/null and b/docs/images/quotes/quote_2.png differ diff --git a/docs/images/quotes/quote_3.png b/docs/images/quotes/quote_3.png new file mode 100644 index 0000000..1829abd Binary files /dev/null and b/docs/images/quotes/quote_3.png differ diff --git a/docs/images/quotes/quote_4.png b/docs/images/quotes/quote_4.png new file mode 100644 index 0000000..6450879 Binary files /dev/null and b/docs/images/quotes/quote_4.png differ diff --git a/docs/images/quotes/quote_5.png b/docs/images/quotes/quote_5.png new file mode 100644 index 0000000..06d174f Binary files /dev/null and b/docs/images/quotes/quote_5.png differ diff --git a/docs/images/quotes/quote_6.png b/docs/images/quotes/quote_6.png new file mode 100644 index 0000000..d2eec3e Binary files /dev/null and b/docs/images/quotes/quote_6.png differ diff --git a/docs/images/titleBlock/a4.png b/docs/images/titleBlock/a4.png new file mode 100644 index 0000000..2c77df0 Binary files /dev/null and b/docs/images/titleBlock/a4.png differ diff --git a/docs/images/titleBlock/a4_2.png b/docs/images/titleBlock/a4_2.png new file mode 100644 index 0000000..690da4a Binary files /dev/null and b/docs/images/titleBlock/a4_2.png differ diff --git a/docs/images/titleBlock/titleblock.png b/docs/images/titleBlock/titleblock.png new file mode 100644 index 0000000..afa4a12 Binary files /dev/null and b/docs/images/titleBlock/titleblock.png differ diff --git a/docs/quotes.scad.md b/docs/quotes.scad.md new file mode 100644 index 0000000..1b07bfc --- /dev/null +++ b/docs/quotes.scad.md @@ -0,0 +1,169 @@ +# LibFile: quotes.scad + + +To use, add the following lines to the beginning of your file: + + include ; + include ; + +## 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:** + +By Position | 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 + +quote() Example 1 + + include ; + include ; + quote(length=100, textSize=50); + +

+ +**Example 2:** Spin -90 + +quote() Example 2 + + include ; + include ; + quote(length=100, textSize=50,spin=-90); + +

+ +**Example 3:** Orient FRONT + +quote() Example 3 + + include ; + include ; + quote(length=100, textSize=50,orient=FRONT); + +

+ +**Example 4:** Orient TOP + +quote() Example 4 + + include ; + include ; + quote(length=100, orient=TOP); + +

+ +**Example 5:** offsetFromOrigin 20 + +quote() Example 5 + + include ; + include ; + quote(length=100, offsetFromOrigin=20); + +

+ +**Example 6:** extendBeyondDimLines 20 + +quote() Example 6 + + include ; + include ; + quote(length=100, extendBeyondDimLines=20); + +

+ +--- + +### 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:** + +By Position | 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:** + +arrowed\_line() Example 1 + + include ; + include ; + arrowed_line([0,0], [50,50], width=0.5, endcap_width=5); + +

+ +--- + +### 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:** + +By Position | 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:** + +ext\_line() Example 1 + + include ; + include ; + ext_line([0,0], [50,50], width=0.5); + +

+ +--- + diff --git a/docs/titleBlock.scad.md b/docs/titleBlock.scad.md new file mode 100644 index 0000000..7e8facf --- /dev/null +++ b/docs/titleBlock.scad.md @@ -0,0 +1,165 @@ +# LibFile: titleBlock.scad + + +To use, add the following lines to the beginning of your file: + + include ; + include ; + include ; + +## 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:** + +By Position | 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 + +titleBlock() Example 1 + +
+ + include ; + include ; + include ; + 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:** + +By Position | 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 + +A4 Example 1 + +
+ + include ; + include ; + include ; + A4( onlyMargin = false ); + +**Example 2:** A4 without border + +A4 Example 2 + +
+ + include ; + include ; + include ; + 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:** + +By Position | 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). + +--- + diff --git a/examples.scad b/examples.scad index cb06f15..5c81697 100644 --- a/examples.scad +++ b/examples.scad @@ -1,15 +1,12 @@ include include - - - - -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"); } - } diff --git a/quotes.scad b/quotes.scad index a65dccc..071ee21 100644 --- a/quotes.scad +++ b/quotes.scad @@ -2,6 +2,7 @@ // LibFile: quotes.scad // Includes: // include ; +// include ; // 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); } diff --git a/run b/run new file mode 100755 index 0000000..d249232 --- /dev/null +++ b/run @@ -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 diff --git a/titleBlock.scad b/titleBlock.scad index db6672e..55e4712 100644 --- a/titleBlock.scad +++ b/titleBlock.scad @@ -1,23 +1,76 @@ +////////////////////////////////////////////////////////////////////// +// LibFile: titleBlock.scad +// Includes: +// include ; +// include ; +// include ; +// FileGroup: TitleBlock +// FileSummary: Title Block +////////////////////////////////////////////////////////////////////// include include +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() + ; + }