cadbuildr-frames 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cadbuildr_frames-0.2.0/.github/workflows/publish-pypi.yml +54 -0
- cadbuildr_frames-0.2.0/.gitignore +162 -0
- cadbuildr_frames-0.2.0/LICENSE +21 -0
- cadbuildr_frames-0.2.0/PKG-INFO +214 -0
- cadbuildr_frames-0.2.0/README.md +204 -0
- cadbuildr_frames-0.2.0/cadbuildr/__init__.py +3 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/__init__.py +78 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/connectors.py +103 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/cut_list.py +99 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/frame.py +493 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/geometry.py +276 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/layout.py +517 -0
- cadbuildr_frames-0.2.0/cadbuildr/frames/profiles.py +318 -0
- cadbuildr_frames-0.2.0/examples/frames_showcase.py +83 -0
- cadbuildr_frames-0.2.0/pyproject.toml +28 -0
- cadbuildr_frames-0.2.0/tests/test_connectors.py +183 -0
- cadbuildr_frames-0.2.0/tests/test_frames.py +229 -0
- cadbuildr_frames-0.2.0/uv.lock +813 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes the package to PyPI when a version tag (vX.Y.Z) is pushed.
|
|
4
|
+
# Uses PyPI Trusted Publishing (OIDC) — no token stored in secrets. Configure the
|
|
5
|
+
# trusted publisher for project "cadbuildr-frames" at https://pypi.org/manage/account/publishing/.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- "v*"
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v6
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
run: uv python install 3.11
|
|
25
|
+
- name: Build sdist + wheel
|
|
26
|
+
run: uv build
|
|
27
|
+
- name: Check the tag matches the package version
|
|
28
|
+
run: |
|
|
29
|
+
PKG_VERSION="$(python -c 'import tomllib; d=tomllib.load(open("pyproject.toml","rb")); print((d.get("project") or d["tool"]["poetry"])["version"])')"
|
|
30
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
31
|
+
echo "package=$PKG_VERSION tag=$TAG_VERSION"
|
|
32
|
+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
|
|
33
|
+
echo "::error::Tag $TAG_VERSION does not match package version $PKG_VERSION"; exit 1
|
|
34
|
+
fi
|
|
35
|
+
- uses: actions/upload-artifact@v4
|
|
36
|
+
with:
|
|
37
|
+
name: dist
|
|
38
|
+
path: dist/
|
|
39
|
+
|
|
40
|
+
publish:
|
|
41
|
+
needs: build
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
environment:
|
|
44
|
+
name: pypi
|
|
45
|
+
url: https://pypi.org/p/cadbuildr-frames
|
|
46
|
+
permissions:
|
|
47
|
+
id-token: write # required for Trusted Publishing (OIDC)
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/download-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: dist
|
|
52
|
+
path: dist/
|
|
53
|
+
- name: Publish to PyPI
|
|
54
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
110
|
+
.pdm.toml
|
|
111
|
+
.pdm-python
|
|
112
|
+
.pdm-build/
|
|
113
|
+
|
|
114
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
115
|
+
__pypackages__/
|
|
116
|
+
|
|
117
|
+
# Celery stuff
|
|
118
|
+
celerybeat-schedule
|
|
119
|
+
celerybeat.pid
|
|
120
|
+
|
|
121
|
+
# SageMath parsed files
|
|
122
|
+
*.sage.py
|
|
123
|
+
|
|
124
|
+
# Environments
|
|
125
|
+
.env
|
|
126
|
+
.venv
|
|
127
|
+
env/
|
|
128
|
+
venv/
|
|
129
|
+
ENV/
|
|
130
|
+
env.bak/
|
|
131
|
+
venv.bak/
|
|
132
|
+
|
|
133
|
+
# Spyder project settings
|
|
134
|
+
.spyderproject
|
|
135
|
+
.spyproject
|
|
136
|
+
|
|
137
|
+
# Rope project settings
|
|
138
|
+
.ropeproject
|
|
139
|
+
|
|
140
|
+
# mkdocs documentation
|
|
141
|
+
/site
|
|
142
|
+
|
|
143
|
+
# mypy
|
|
144
|
+
.mypy_cache/
|
|
145
|
+
.dmypy.json
|
|
146
|
+
dmypy.json
|
|
147
|
+
|
|
148
|
+
# Pyre type checker
|
|
149
|
+
.pyre/
|
|
150
|
+
|
|
151
|
+
# pytype static type analyzer
|
|
152
|
+
.pytype/
|
|
153
|
+
|
|
154
|
+
# Cython debug symbols
|
|
155
|
+
cython_debug/
|
|
156
|
+
|
|
157
|
+
# PyCharm
|
|
158
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
159
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
160
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
161
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
162
|
+
#.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 cadbuildr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cadbuildr-frames
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Structural and woodworking frames (weldments) on CADbuildr foundation: profiles swept along a skeleton, corner trims, gussets, end caps and a cut list
|
|
5
|
+
Author: CADbuildr Team
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: <4.0.0,>=3.10.0
|
|
8
|
+
Requires-Dist: cadbuildr-foundation<0.3.0,>=0.2.20
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# cadbuildr.frames
|
|
12
|
+
|
|
13
|
+
## Summary
|
|
14
|
+
|
|
15
|
+
Structural and woodworking frames (weldments) built on CADbuildr foundation —
|
|
16
|
+
the Onshape *Frame / Frame trim / Gusset / End cap / Cut list* features as a
|
|
17
|
+
library. A `Frame` sweeps a profile (square/rect/round tube, angle, channel,
|
|
18
|
+
I-beam, flat/round bar, dimensional lumber) along a skeleton of line and arc
|
|
19
|
+
segments, trims the corners (miter, butt "trim to", coped), adds gusset plates
|
|
20
|
+
and end caps, and reports a cut list. Every member is its own `Part` inside the
|
|
21
|
+
frame `Assembly`, so BOMs and exports see real cut pieces.
|
|
22
|
+
|
|
23
|
+
It composes plain foundation operations only — `Extrusion` along each segment,
|
|
24
|
+
`Lathe` for bent (arc) members, cut `Extrusion`s on trim planes for miters and
|
|
25
|
+
butts, and the through member's outline for copes — so it renders anywhere
|
|
26
|
+
foundation does (Prototype app, Hub, Playground, kernel-api). No schema nodes.
|
|
27
|
+
|
|
28
|
+
## Tags
|
|
29
|
+
|
|
30
|
+
cad, python, frames, weldments, structural, steel, tube, lumber, cut-list, assembly
|
|
31
|
+
|
|
32
|
+
## Status
|
|
33
|
+
|
|
34
|
+
yellow
|
|
35
|
+
|
|
36
|
+
## Guidelines
|
|
37
|
+
|
|
38
|
+
- Pure layout maths (`layout.py`) is separate from geometry (`frame.py`): the
|
|
39
|
+
cut list is computed from the skeleton + profiles without a kernel, and the
|
|
40
|
+
Parts are built from that same layout — one source of truth.
|
|
41
|
+
- Named defaults, no silent magic: `DEFAULT_UP` / `FALLBACK_UP` decide profile
|
|
42
|
+
orientation, "longer member runs through" decides butt corners, and every
|
|
43
|
+
rule is documented on `Frame` and below.
|
|
44
|
+
- Unsupported input fails loudly (`ValueError` naming the members): overlapping
|
|
45
|
+
members, a coped member wider than its host, an arc that would need cutting
|
|
46
|
+
back, a gusset on something that is not a two-member corner.
|
|
47
|
+
- Publish-first: depends on `cadbuildr-foundation` from PyPI only.
|
|
48
|
+
|
|
49
|
+
## Dependencies
|
|
50
|
+
|
|
51
|
+
### Upstream
|
|
52
|
+
|
|
53
|
+
- [cadbuildr-foundation](https://pypi.org/project/cadbuildr-foundation/) (PyPI)
|
|
54
|
+
|
|
55
|
+
### Downstream
|
|
56
|
+
|
|
57
|
+
- None yet (to be added to the curated-libraries registry once on PyPI).
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from cadbuildr.foundation import show
|
|
63
|
+
from cadbuildr.frames import EndCap, Frame, Gusset, SquareTube, rectangle
|
|
64
|
+
|
|
65
|
+
# 600 x 400 mm rectangle (skeleton = tube centrelines), 40x40x3 square tube,
|
|
66
|
+
# mitered corners, a gusset in each corner.
|
|
67
|
+
frame = Frame(
|
|
68
|
+
skeleton=rectangle(600, 400),
|
|
69
|
+
profile=SquareTube(40, 3),
|
|
70
|
+
corner="miter",
|
|
71
|
+
gussets=[Gusset(at=(x, y, 0), size=60, thickness=4)
|
|
72
|
+
for x in (-300, 300) for y in (-200, 200)],
|
|
73
|
+
)
|
|
74
|
+
print(frame.cut_list_table())
|
|
75
|
+
show(frame)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
Item Qty Profile Length Angle 1 Angle 2 Ends
|
|
80
|
+
---- --- -------------- ------ ------- ------- -----------
|
|
81
|
+
1 2 SHS 40x40x3 640.0 45.0 45.0 miter/miter
|
|
82
|
+
2 2 SHS 40x40x3 440.0 45.0 45.0 miter/miter
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The same rectangle with `corner="butt"`: the 600 rails run through (640 long,
|
|
86
|
+
square ends), the 400 sides are trimmed to their faces (360 long).
|
|
87
|
+
|
|
88
|
+
`frame.cut_list()` returns `CutListItem` rows: `profile`, `length` (overall,
|
|
89
|
+
long point to long point, mm), `end_angles` (degrees from square: 0 = square,
|
|
90
|
+
45 = corner miter), `end_cuts` (`free`, `miter`, `butt`, `through`, `coped`,
|
|
91
|
+
`continuous`), `count`, `members` (Part names) and `bend_radius` for arcs.
|
|
92
|
+
|
|
93
|
+
### Skeleton
|
|
94
|
+
|
|
95
|
+
- `Line3D(start, end)`, `Arc3D(start, through, end)` — segments in mm.
|
|
96
|
+
- Helpers: `rectangle(width, depth, center)` (closed, XY plane),
|
|
97
|
+
`polyline(points, closed=False)`, `box_edges(width, depth, height)` (the 12
|
|
98
|
+
edges of a box / table frame).
|
|
99
|
+
- Segments sharing an end point are joined. An end lying inside another
|
|
100
|
+
straight member is a T-junction.
|
|
101
|
+
|
|
102
|
+
### Profiles
|
|
103
|
+
|
|
104
|
+
| Profile | Arguments |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `SquareTube(size, wall)` | square hollow section |
|
|
107
|
+
| `RectTube(width, height, wall)` | rectangular hollow section |
|
|
108
|
+
| `RoundTube(diameter, wall)` | round tube |
|
|
109
|
+
| `RoundBar(diameter)`, `RectBar(width, height)` | solid bar / flat bar |
|
|
110
|
+
| `Angle(width, height, thickness)` | L section, heel at the -u/-v corner |
|
|
111
|
+
| `Channel(height, width, web, flange)` | C channel, web at -u |
|
|
112
|
+
| `IBeam(height, width, web, flange)` | I / H beam |
|
|
113
|
+
| `Lumber("2x4")` | dimensional lumber, actual dressed size (1.5" x 3.5") |
|
|
114
|
+
|
|
115
|
+
Profiles are centred on the skeleton at their bounding-box centre. `u` (the
|
|
116
|
+
first dimension) lies across the member in the frame's plane, `v` (the
|
|
117
|
+
second) points to the `up` side: for a planar skeleton `up` is its plane
|
|
118
|
+
normal (towards +Z), otherwise world +Z; members parallel to `up` (table
|
|
119
|
+
posts) use world +X. Pass `up=` to change it. Tube corners are sharp and
|
|
120
|
+
beams have no root fillets (a simplification).
|
|
121
|
+
|
|
122
|
+
### Corners and junctions
|
|
123
|
+
|
|
124
|
+
| Node | Treatment |
|
|
125
|
+
|---|---|
|
|
126
|
+
| free end | square cut (end caps go here) |
|
|
127
|
+
| two members, `corner="miter"` | both cut on the bisector plane |
|
|
128
|
+
| two members, `corner="butt"` | the longer member runs through (square end, extended over the other), the other is trimmed to its face; ties: the first segment runs through; an arc always runs through a line |
|
|
129
|
+
| two members, `corner="coped"` | as butt, but the trimmed member is cut to the through member's outer shape (round tube to round tube) |
|
|
130
|
+
| collinear / tangent ends | continuous, no cut |
|
|
131
|
+
| three or more members | the longest runs through, the others are butted (coped with `corner="coped"`) |
|
|
132
|
+
| T-junction | the end is butted (coped) onto the member it lands on |
|
|
133
|
+
|
|
134
|
+
### Gussets and end caps
|
|
135
|
+
|
|
136
|
+
- `Gusset(at=corner_point, size=60, thickness=5, position="center")` — a
|
|
137
|
+
triangular plate in the corner with both legs `size` long from the members'
|
|
138
|
+
inner corner. `position`: `"center"` (frame mid-plane), `"top"` / `"bottom"`
|
|
139
|
+
(flush with that face). Only on two-member corners.
|
|
140
|
+
- `EndCap(thickness=3)` — a plate of the outer outline on every free end,
|
|
141
|
+
added beyond the end (cut lengths are unchanged).
|
|
142
|
+
|
|
143
|
+
Members are `FrameMember` Parts named `member_1…` (skeleton order), plates
|
|
144
|
+
`gusset_N` / `end_cap_N`; `frame.members`, `frame.gussets`, `frame.end_caps`
|
|
145
|
+
list them.
|
|
146
|
+
|
|
147
|
+
### Connector hook (joint hardware)
|
|
148
|
+
|
|
149
|
+
`Frame(..., connector=...)` is the one extension point for joint hardware —
|
|
150
|
+
brackets, fasteners, end caps — that a library (e.g. `cadbuildr-tslot`)
|
|
151
|
+
places on the frame. It is called once per junction, after the layout is
|
|
152
|
+
solved and before any member is added, so it can also machine the members.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from cadbuildr.frames import Connection, ConnectorRule, Placed, basis_transform
|
|
156
|
+
|
|
157
|
+
class PostsThrough(ConnectorRule):
|
|
158
|
+
def choose_through(self, node, ends): # optional
|
|
159
|
+
return next((i for i, e in enumerate(ends) if abs(e.into[2]) > 0.99), None)
|
|
160
|
+
|
|
161
|
+
def prepare_member(self, part): # optional, once per member
|
|
162
|
+
... # e.g. add slot anchors
|
|
163
|
+
|
|
164
|
+
def connect(self, junction, layout): # per junction
|
|
165
|
+
if junction.kind == "free":
|
|
166
|
+
return None
|
|
167
|
+
end = junction.butting[0]
|
|
168
|
+
return Connection(
|
|
169
|
+
components=[Placed(MyBracket(), basis_transform(junction.node, end.basis))],
|
|
170
|
+
machining=[(end, lambda part: part.add_operation(...))],
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
Frame(box_edges(600, 400, 300), profile, corner="butt", connector=PostsThrough())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- A plain callable `connector(junction) -> Connection | None` works too.
|
|
177
|
+
- `Junction`: `kind` (`free`, `continuous`, `corner`, `tee`, `multi`),
|
|
178
|
+
`node`, `through` (the member running through, `None` for free /
|
|
179
|
+
continuous / mitered nodes), `butting` (the trimmed members), `ends`,
|
|
180
|
+
`corner`, `up`. Each `JunctionEnd` has `member` (`MemberLayout`), `which`
|
|
181
|
+
(`"start"` / `"end"`, `None` for a T host), `into` (unit direction from the
|
|
182
|
+
node into the member), `basis` (member x / profile u / v at the node),
|
|
183
|
+
`profile` and `cut` (the `EndCut`, with `extension`).
|
|
184
|
+
- `choose_through` overrides "longest runs through" at butt / coped / multi
|
|
185
|
+
nodes (return an index into `ends`, or `None`).
|
|
186
|
+
- Machining functions get the `FrameMember` (local coordinates: start at
|
|
187
|
+
the origin, +X along the member); `part.plane(origin, x, z)`,
|
|
188
|
+
`part.local_point(p)`, `part.local_dir(v)` and `part.length_range` help.
|
|
189
|
+
- `frame.junctions`, `frame.connections` and `frame.connectors` list what
|
|
190
|
+
was found and added. Without a connector the frame is unchanged.
|
|
191
|
+
|
|
192
|
+
## Not supported (yet)
|
|
193
|
+
|
|
194
|
+
- T-junctions onto arc members; mitering two arcs that are not tangent.
|
|
195
|
+
- Per-corner overrides (choose which member runs through), profile offsets
|
|
196
|
+
(e.g. an angle's heel on the skeleton) and profile rotation other than
|
|
197
|
+
`up=`.
|
|
198
|
+
- Weld beads, tube corner radii, hole patterns.
|
|
199
|
+
|
|
200
|
+
## Example
|
|
201
|
+
|
|
202
|
+
`examples/frames_showcase.py` builds four small frames — a mitered rectangle
|
|
203
|
+
with gussets, a table base (butted three-member corners, capped feet), a bent
|
|
204
|
+
round-tube rail with a coped post, and a channel bracket with a butt corner —
|
|
205
|
+
and prints their cut lists. Rendered in the Playground:
|
|
206
|
+
[docs/funnel-evidence/frames-weldments-library/showcase.png](../../../../docs/funnel-evidence/frames-weldments-library/showcase.png).
|
|
207
|
+
|
|
208
|
+
User docs: `tsjs/apps/documentation/pages/Foundation/Libraries/frames.mdx`.
|
|
209
|
+
|
|
210
|
+
## Tests
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
cd py && uv run --frozen --package cadbuildr-frames python -m pytest packages/cadbuildr/frames/tests -q
|
|
214
|
+
```
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# cadbuildr.frames
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Structural and woodworking frames (weldments) built on CADbuildr foundation —
|
|
6
|
+
the Onshape *Frame / Frame trim / Gusset / End cap / Cut list* features as a
|
|
7
|
+
library. A `Frame` sweeps a profile (square/rect/round tube, angle, channel,
|
|
8
|
+
I-beam, flat/round bar, dimensional lumber) along a skeleton of line and arc
|
|
9
|
+
segments, trims the corners (miter, butt "trim to", coped), adds gusset plates
|
|
10
|
+
and end caps, and reports a cut list. Every member is its own `Part` inside the
|
|
11
|
+
frame `Assembly`, so BOMs and exports see real cut pieces.
|
|
12
|
+
|
|
13
|
+
It composes plain foundation operations only — `Extrusion` along each segment,
|
|
14
|
+
`Lathe` for bent (arc) members, cut `Extrusion`s on trim planes for miters and
|
|
15
|
+
butts, and the through member's outline for copes — so it renders anywhere
|
|
16
|
+
foundation does (Prototype app, Hub, Playground, kernel-api). No schema nodes.
|
|
17
|
+
|
|
18
|
+
## Tags
|
|
19
|
+
|
|
20
|
+
cad, python, frames, weldments, structural, steel, tube, lumber, cut-list, assembly
|
|
21
|
+
|
|
22
|
+
## Status
|
|
23
|
+
|
|
24
|
+
yellow
|
|
25
|
+
|
|
26
|
+
## Guidelines
|
|
27
|
+
|
|
28
|
+
- Pure layout maths (`layout.py`) is separate from geometry (`frame.py`): the
|
|
29
|
+
cut list is computed from the skeleton + profiles without a kernel, and the
|
|
30
|
+
Parts are built from that same layout — one source of truth.
|
|
31
|
+
- Named defaults, no silent magic: `DEFAULT_UP` / `FALLBACK_UP` decide profile
|
|
32
|
+
orientation, "longer member runs through" decides butt corners, and every
|
|
33
|
+
rule is documented on `Frame` and below.
|
|
34
|
+
- Unsupported input fails loudly (`ValueError` naming the members): overlapping
|
|
35
|
+
members, a coped member wider than its host, an arc that would need cutting
|
|
36
|
+
back, a gusset on something that is not a two-member corner.
|
|
37
|
+
- Publish-first: depends on `cadbuildr-foundation` from PyPI only.
|
|
38
|
+
|
|
39
|
+
## Dependencies
|
|
40
|
+
|
|
41
|
+
### Upstream
|
|
42
|
+
|
|
43
|
+
- [cadbuildr-foundation](https://pypi.org/project/cadbuildr-foundation/) (PyPI)
|
|
44
|
+
|
|
45
|
+
### Downstream
|
|
46
|
+
|
|
47
|
+
- None yet (to be added to the curated-libraries registry once on PyPI).
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from cadbuildr.foundation import show
|
|
53
|
+
from cadbuildr.frames import EndCap, Frame, Gusset, SquareTube, rectangle
|
|
54
|
+
|
|
55
|
+
# 600 x 400 mm rectangle (skeleton = tube centrelines), 40x40x3 square tube,
|
|
56
|
+
# mitered corners, a gusset in each corner.
|
|
57
|
+
frame = Frame(
|
|
58
|
+
skeleton=rectangle(600, 400),
|
|
59
|
+
profile=SquareTube(40, 3),
|
|
60
|
+
corner="miter",
|
|
61
|
+
gussets=[Gusset(at=(x, y, 0), size=60, thickness=4)
|
|
62
|
+
for x in (-300, 300) for y in (-200, 200)],
|
|
63
|
+
)
|
|
64
|
+
print(frame.cut_list_table())
|
|
65
|
+
show(frame)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
Item Qty Profile Length Angle 1 Angle 2 Ends
|
|
70
|
+
---- --- -------------- ------ ------- ------- -----------
|
|
71
|
+
1 2 SHS 40x40x3 640.0 45.0 45.0 miter/miter
|
|
72
|
+
2 2 SHS 40x40x3 440.0 45.0 45.0 miter/miter
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The same rectangle with `corner="butt"`: the 600 rails run through (640 long,
|
|
76
|
+
square ends), the 400 sides are trimmed to their faces (360 long).
|
|
77
|
+
|
|
78
|
+
`frame.cut_list()` returns `CutListItem` rows: `profile`, `length` (overall,
|
|
79
|
+
long point to long point, mm), `end_angles` (degrees from square: 0 = square,
|
|
80
|
+
45 = corner miter), `end_cuts` (`free`, `miter`, `butt`, `through`, `coped`,
|
|
81
|
+
`continuous`), `count`, `members` (Part names) and `bend_radius` for arcs.
|
|
82
|
+
|
|
83
|
+
### Skeleton
|
|
84
|
+
|
|
85
|
+
- `Line3D(start, end)`, `Arc3D(start, through, end)` — segments in mm.
|
|
86
|
+
- Helpers: `rectangle(width, depth, center)` (closed, XY plane),
|
|
87
|
+
`polyline(points, closed=False)`, `box_edges(width, depth, height)` (the 12
|
|
88
|
+
edges of a box / table frame).
|
|
89
|
+
- Segments sharing an end point are joined. An end lying inside another
|
|
90
|
+
straight member is a T-junction.
|
|
91
|
+
|
|
92
|
+
### Profiles
|
|
93
|
+
|
|
94
|
+
| Profile | Arguments |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `SquareTube(size, wall)` | square hollow section |
|
|
97
|
+
| `RectTube(width, height, wall)` | rectangular hollow section |
|
|
98
|
+
| `RoundTube(diameter, wall)` | round tube |
|
|
99
|
+
| `RoundBar(diameter)`, `RectBar(width, height)` | solid bar / flat bar |
|
|
100
|
+
| `Angle(width, height, thickness)` | L section, heel at the -u/-v corner |
|
|
101
|
+
| `Channel(height, width, web, flange)` | C channel, web at -u |
|
|
102
|
+
| `IBeam(height, width, web, flange)` | I / H beam |
|
|
103
|
+
| `Lumber("2x4")` | dimensional lumber, actual dressed size (1.5" x 3.5") |
|
|
104
|
+
|
|
105
|
+
Profiles are centred on the skeleton at their bounding-box centre. `u` (the
|
|
106
|
+
first dimension) lies across the member in the frame's plane, `v` (the
|
|
107
|
+
second) points to the `up` side: for a planar skeleton `up` is its plane
|
|
108
|
+
normal (towards +Z), otherwise world +Z; members parallel to `up` (table
|
|
109
|
+
posts) use world +X. Pass `up=` to change it. Tube corners are sharp and
|
|
110
|
+
beams have no root fillets (a simplification).
|
|
111
|
+
|
|
112
|
+
### Corners and junctions
|
|
113
|
+
|
|
114
|
+
| Node | Treatment |
|
|
115
|
+
|---|---|
|
|
116
|
+
| free end | square cut (end caps go here) |
|
|
117
|
+
| two members, `corner="miter"` | both cut on the bisector plane |
|
|
118
|
+
| two members, `corner="butt"` | the longer member runs through (square end, extended over the other), the other is trimmed to its face; ties: the first segment runs through; an arc always runs through a line |
|
|
119
|
+
| two members, `corner="coped"` | as butt, but the trimmed member is cut to the through member's outer shape (round tube to round tube) |
|
|
120
|
+
| collinear / tangent ends | continuous, no cut |
|
|
121
|
+
| three or more members | the longest runs through, the others are butted (coped with `corner="coped"`) |
|
|
122
|
+
| T-junction | the end is butted (coped) onto the member it lands on |
|
|
123
|
+
|
|
124
|
+
### Gussets and end caps
|
|
125
|
+
|
|
126
|
+
- `Gusset(at=corner_point, size=60, thickness=5, position="center")` — a
|
|
127
|
+
triangular plate in the corner with both legs `size` long from the members'
|
|
128
|
+
inner corner. `position`: `"center"` (frame mid-plane), `"top"` / `"bottom"`
|
|
129
|
+
(flush with that face). Only on two-member corners.
|
|
130
|
+
- `EndCap(thickness=3)` — a plate of the outer outline on every free end,
|
|
131
|
+
added beyond the end (cut lengths are unchanged).
|
|
132
|
+
|
|
133
|
+
Members are `FrameMember` Parts named `member_1…` (skeleton order), plates
|
|
134
|
+
`gusset_N` / `end_cap_N`; `frame.members`, `frame.gussets`, `frame.end_caps`
|
|
135
|
+
list them.
|
|
136
|
+
|
|
137
|
+
### Connector hook (joint hardware)
|
|
138
|
+
|
|
139
|
+
`Frame(..., connector=...)` is the one extension point for joint hardware —
|
|
140
|
+
brackets, fasteners, end caps — that a library (e.g. `cadbuildr-tslot`)
|
|
141
|
+
places on the frame. It is called once per junction, after the layout is
|
|
142
|
+
solved and before any member is added, so it can also machine the members.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from cadbuildr.frames import Connection, ConnectorRule, Placed, basis_transform
|
|
146
|
+
|
|
147
|
+
class PostsThrough(ConnectorRule):
|
|
148
|
+
def choose_through(self, node, ends): # optional
|
|
149
|
+
return next((i for i, e in enumerate(ends) if abs(e.into[2]) > 0.99), None)
|
|
150
|
+
|
|
151
|
+
def prepare_member(self, part): # optional, once per member
|
|
152
|
+
... # e.g. add slot anchors
|
|
153
|
+
|
|
154
|
+
def connect(self, junction, layout): # per junction
|
|
155
|
+
if junction.kind == "free":
|
|
156
|
+
return None
|
|
157
|
+
end = junction.butting[0]
|
|
158
|
+
return Connection(
|
|
159
|
+
components=[Placed(MyBracket(), basis_transform(junction.node, end.basis))],
|
|
160
|
+
machining=[(end, lambda part: part.add_operation(...))],
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
Frame(box_edges(600, 400, 300), profile, corner="butt", connector=PostsThrough())
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- A plain callable `connector(junction) -> Connection | None` works too.
|
|
167
|
+
- `Junction`: `kind` (`free`, `continuous`, `corner`, `tee`, `multi`),
|
|
168
|
+
`node`, `through` (the member running through, `None` for free /
|
|
169
|
+
continuous / mitered nodes), `butting` (the trimmed members), `ends`,
|
|
170
|
+
`corner`, `up`. Each `JunctionEnd` has `member` (`MemberLayout`), `which`
|
|
171
|
+
(`"start"` / `"end"`, `None` for a T host), `into` (unit direction from the
|
|
172
|
+
node into the member), `basis` (member x / profile u / v at the node),
|
|
173
|
+
`profile` and `cut` (the `EndCut`, with `extension`).
|
|
174
|
+
- `choose_through` overrides "longest runs through" at butt / coped / multi
|
|
175
|
+
nodes (return an index into `ends`, or `None`).
|
|
176
|
+
- Machining functions get the `FrameMember` (local coordinates: start at
|
|
177
|
+
the origin, +X along the member); `part.plane(origin, x, z)`,
|
|
178
|
+
`part.local_point(p)`, `part.local_dir(v)` and `part.length_range` help.
|
|
179
|
+
- `frame.junctions`, `frame.connections` and `frame.connectors` list what
|
|
180
|
+
was found and added. Without a connector the frame is unchanged.
|
|
181
|
+
|
|
182
|
+
## Not supported (yet)
|
|
183
|
+
|
|
184
|
+
- T-junctions onto arc members; mitering two arcs that are not tangent.
|
|
185
|
+
- Per-corner overrides (choose which member runs through), profile offsets
|
|
186
|
+
(e.g. an angle's heel on the skeleton) and profile rotation other than
|
|
187
|
+
`up=`.
|
|
188
|
+
- Weld beads, tube corner radii, hole patterns.
|
|
189
|
+
|
|
190
|
+
## Example
|
|
191
|
+
|
|
192
|
+
`examples/frames_showcase.py` builds four small frames — a mitered rectangle
|
|
193
|
+
with gussets, a table base (butted three-member corners, capped feet), a bent
|
|
194
|
+
round-tube rail with a coped post, and a channel bracket with a butt corner —
|
|
195
|
+
and prints their cut lists. Rendered in the Playground:
|
|
196
|
+
[docs/funnel-evidence/frames-weldments-library/showcase.png](../../../../docs/funnel-evidence/frames-weldments-library/showcase.png).
|
|
197
|
+
|
|
198
|
+
User docs: `tsjs/apps/documentation/pages/Foundation/Libraries/frames.mdx`.
|
|
199
|
+
|
|
200
|
+
## Tests
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
cd py && uv run --frozen --package cadbuildr-frames python -m pytest packages/cadbuildr/frames/tests -q
|
|
204
|
+
```
|