|
| 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