Skip to content

Commit b6a71b8

Browse files
Copilotdorkmo
andcommitted
Add GitHub Actions workflow to auto-regenerate cnclayout.svg with detailed parts
Co-authored-by: dorkmo <1923070+dorkmo@users.noreply.github.com>
1 parent fe77cd6 commit b6a71b8

File tree

2 files changed

+288
-0
lines changed

2 files changed

+288
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Generate CNC Layout SVG
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'LifeTrac-v25/mechanical_design/cnclayout.scad'
8+
- 'LifeTrac-v25/mechanical_design/parts/*.scad'
9+
- 'LifeTrac-v25/mechanical_design/openscad/lifetrac_v25_params.scad'
10+
pull_request:
11+
branches: [ main, master ]
12+
paths:
13+
- 'LifeTrac-v25/mechanical_design/cnclayout.scad'
14+
- 'LifeTrac-v25/mechanical_design/parts/*.scad'
15+
- 'LifeTrac-v25/mechanical_design/openscad/lifetrac_v25_params.scad'
16+
workflow_dispatch:
17+
18+
jobs:
19+
generate-cnclayout:
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
contents: write
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
# Ensure the workflow checks out the PR branch (not the base branch) for pull_request events
30+
ref: ${{ github.head_ref || github.ref_name }}
31+
32+
- name: Install OpenSCAD
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y openscad xvfb
36+
37+
- name: Generate Combined CNC Layout SVG
38+
run: |
39+
cd LifeTrac-v25/mechanical_design
40+
41+
echo "========================================="
42+
echo "Generating Combined CNC Layout SVG"
43+
echo "========================================="
44+
45+
# Use xvfb-run to provide a virtual display for OpenSCAD rendering
46+
# For 2D projections, use top-down orthographic view
47+
xvfb-run -a openscad --render \
48+
--imgsize=4096,8192 \
49+
--colorscheme=Tomorrow \
50+
--projection=ortho \
51+
--camera=0,0,0,0,0,0,3000 \
52+
-o cnclayout.svg \
53+
cnclayout.scad 2>&1 | grep -v "WARNING" || true
54+
55+
# Verify the SVG was created
56+
if [ -f cnclayout.svg ]; then
57+
echo "✅ Combined CNC Layout SVG generated successfully"
58+
ls -lh cnclayout.svg
59+
du -h cnclayout.svg
60+
61+
# Count paths/shapes in SVG as a sanity check
62+
echo "Checking SVG content..."
63+
path_count=$(grep -o "<path" cnclayout.svg | wc -l)
64+
echo "Number of paths in SVG: ${path_count}"
65+
66+
if [ ${path_count} -gt 50 ]; then
67+
echo "✅ SVG contains ${path_count} paths (expected 50+)"
68+
else
69+
echo "⚠️ SVG only contains ${path_count} paths - may be incomplete"
70+
fi
71+
else
72+
echo "❌ Failed to generate Combined CNC Layout SVG"
73+
exit 1
74+
fi
75+
76+
- name: Update README with CNC layout SVG
77+
run: |
78+
cd LifeTrac-v25/mechanical_design
79+
80+
# Check if README already has CNC layout section
81+
if ! grep -q "## CNC Cutting Layout" README.md; then
82+
echo "Adding CNC layout section to README..."
83+
84+
cat >> README.md << 'EOF'
85+
86+
## CNC Cutting Layout
87+
88+
### Combined Layout (All Parts)
89+
![CNC Cutting Layout - All Parts](cnclayout.svg)
90+
91+
The combined CNC layout includes all 23 sheet metal parts with complete manufacturing details:
92+
- Mounting holes with proper clearances
93+
- Pivot holes for arm and cylinder connections
94+
- Arc slots for cross beam clearance (inner panels)
95+
- Lightening holes for weight reduction
96+
- Anti-slip hole patterns (standing deck)
97+
- All parts properly spaced for efficient cutting
98+
99+
**Material Specifications:**
100+
- Half-inch (1/2") plate parts: 14 parts total
101+
- Quarter-inch (1/4") plate parts: 9 parts total
102+
103+
EOF
104+
echo "✓ README updated with CNC layout section"
105+
else
106+
echo "ℹ️ README already has CNC layout section"
107+
fi
108+
109+
- name: Commit and push if changed
110+
run: |
111+
cd LifeTrac-v25/mechanical_design
112+
git config --local user.email "action@github.com"
113+
git config --local user.name "GitHub Action"
114+
git add cnclayout.svg README.md || true
115+
116+
if git diff --staged --quiet; then
117+
echo "ℹ️ No changes to commit"
118+
else
119+
echo "📝 Committing changes..."
120+
git commit -m "Update combined CNC layout SVG with detailed parts [skip ci]"
121+
git push
122+
echo "✅ Changes pushed successfully"
123+
fi
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# CNC Layout SVG Regeneration
2+
3+
## Overview
4+
5+
The `cnclayout.svg` file is automatically regenerated whenever the source files change. This ensures the SVG always reflects the latest part designs with all manufacturing details.
6+
7+
## Automatic Regeneration
8+
9+
### GitHub Actions Workflow
10+
11+
The workflow `.github/workflows/generate-cnclayout-svg.yml` automatically:
12+
13+
1. **Triggers on changes to:**
14+
- `cnclayout.scad` (main layout file)
15+
- `parts/*.scad` (individual part files)
16+
- `openscad/lifetrac_v25_params.scad` (shared parameters)
17+
18+
2. **Regenerates:**
19+
- `cnclayout.svg` - Combined layout with all 23 parts
20+
- Updates README with current information
21+
22+
3. **Commits back:**
23+
- The updated SVG file
24+
- Any README changes
25+
26+
### What Gets Included
27+
28+
The regenerated SVG includes all manufacturing details from the individual part files:
29+
30+
#### Half-Inch (1/2") Plate Parts
31+
- **Side panels**: Pivot holes (38.1mm), cylinder mounts, wheel axle holes, arc slots
32+
- **Wheel mounts**: Motor shaft hole (80mm), 8-bolt pattern, corner mounts
33+
- **Cylinder lugs**: Pivot holes (25.4mm), 4 base mounting holes
34+
- **Rear crossmember**: Panel mounting holes, lightening holes
35+
36+
#### Quarter-Inch (1/4") Plate Parts
37+
- **Standing deck**: Anti-slip hole pattern (25mm holes on 80mm grid), corner mounts
38+
- **Bucket bottom**: Edge mounting holes, quick-attach connection holes
39+
- **Bucket sides**: Assembly holes for panel connections
40+
41+
## Manual Regeneration
42+
43+
### Prerequisites
44+
45+
- OpenSCAD installed: `sudo apt-get install openscad`
46+
- For headless systems: `sudo apt-get install xvfb`
47+
48+
### Command
49+
50+
```bash
51+
cd LifeTrac-v25/mechanical_design
52+
53+
# With display
54+
openscad --render -o cnclayout.svg cnclayout.scad
55+
56+
# Headless (using xvfb)
57+
xvfb-run -a openscad --render \
58+
--imgsize=4096,8192 \
59+
--colorscheme=Tomorrow \
60+
--projection=ortho \
61+
--camera=0,0,0,0,0,0,3000 \
62+
-o cnclayout.svg \
63+
cnclayout.scad
64+
```
65+
66+
### Render Options Explained
67+
68+
- `--render`: Full render (vs preview mode)
69+
- `--imgsize=4096,8192`: Large image for detailed parts
70+
- `--colorscheme=Tomorrow`: Color scheme for better visibility
71+
- `--projection=ortho`: Orthographic projection (no perspective)
72+
- `--camera=0,0,0,0,0,0,3000`: Top-down view from 3000mm above
73+
74+
## Troubleshooting
75+
76+
### SVG is empty or incomplete
77+
78+
**Problem**: SVG file exists but shows no parts or only some parts
79+
80+
**Solutions**:
81+
1. Check that all part files in `parts/` directory are valid OpenSCAD files
82+
2. Verify `openscad/lifetrac_v25_params.scad` has all required parameters
83+
3. Look for OpenSCAD errors in the workflow logs
84+
4. Try rendering manually to see error messages
85+
86+
### SVG is too large
87+
88+
**Problem**: SVG file is multiple megabytes and slow to load
89+
90+
**Solutions**:
91+
1. This is expected - the SVG contains detailed geometry for all parts
92+
2. For smaller files, use individual part SVGs from `output/svg/parts/`
93+
3. Reduce `--imgsize` parameter (but may lose detail)
94+
95+
### Parts missing details
96+
97+
**Problem**: Parts show as simple outlines without holes
98+
99+
**Solutions**:
100+
1. Verify individual part files contain the features (holes, slots, etc.)
101+
2. Ensure `projection(cut=true)` is used in `cnclayout.scad`
102+
3. Check that parts are 3D models, not 2D shapes (projection needs 3D input)
103+
104+
### Workflow fails in GitHub Actions
105+
106+
**Problem**: Workflow runs but fails to generate SVG
107+
108+
**Solutions**:
109+
1. Check workflow logs for OpenSCAD errors
110+
2. Verify all file paths are correct
111+
3. Ensure OpenSCAD syntax is valid (test locally first)
112+
4. Check that xvfb is properly installed in the workflow
113+
114+
## Architecture Notes
115+
116+
### Why Automatic Regeneration?
117+
118+
The SVG is a **rendered output** from the source SCAD files, similar to how:
119+
- Assembly images are rendered from 3D models
120+
- PDFs are compiled from LaTeX source
121+
- Binaries are compiled from source code
122+
123+
Automatic regeneration ensures:
124+
1. **Consistency**: SVG always matches the source
125+
2. **Accuracy**: No manual export errors
126+
3. **Traceability**: Git history shows what changed
127+
4. **Convenience**: No manual steps required
128+
129+
### File Relationships
130+
131+
```
132+
Source Files (hand-edited):
133+
├── parts/side_panel.scad
134+
├── parts/wheel_mount.scad
135+
├── parts/cylinder_lug.scad
136+
├── ... (other parts)
137+
└── cnclayout.scad (imports and layouts parts)
138+
139+
├── Uses projection(cut=true) to create 2D
140+
141+
└── OpenSCAD renders to:
142+
143+
└── cnclayout.svg (auto-generated output)
144+
```
145+
146+
### Workflow Integration
147+
148+
```
149+
Developer workflow:
150+
1. Edit part file: parts/wheel_mount.scad
151+
2. Commit and push changes
152+
3. GitHub Actions detects change
153+
4. Workflow runs:
154+
- Installs OpenSCAD
155+
- Renders cnclayout.svg
156+
- Commits updated SVG
157+
5. SVG is now current with latest changes
158+
```
159+
160+
## See Also
161+
162+
- `INDIVIDUAL_PARTS_GUIDE.md` - Guide for individual part SVG exports
163+
- `parts/README_EXPORTS.md` - Export documentation
164+
- `.github/workflows/generate-cnclayout-svg.yml` - Workflow file
165+
- `.github/workflows/generate-part-svgs.yml` - Individual parts workflow

0 commit comments

Comments
 (0)