flatcam externalized
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,2 @@
|
|||||||
gcode/
|
gcode/
|
||||||
gerbers/
|
gerbers/
|
||||||
.flatcam-env/
|
|
||||||
flatcam-beta/
|
|
||||||
68
Readme.md
68
Readme.md
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
Automates the conversion of a KiCad v9 `F.Paste` and `B.Paste` Gerber to G-code for CNC milling a solder paste stencil, using FlatCAM beta 8.995 headless. Tested on Ubuntu 24.04 with Python 3.12 and a Frezu 3040 / FluidNC controller.
|
Automates the conversion of a KiCad v9 `F.Paste` and `B.Paste` Gerber to G-code for CNC milling a solder paste stencil, using FlatCAM beta 8.995 headless. Tested on Ubuntu 24.04 with Python 3.12 and a Frezu 3040 / FluidNC controller.
|
||||||
|
|
||||||
|
This project shares a single FlatCAM install (`~/flatcam-beta`) with other `kicad2*` pipelines (e.g. `kicad2outlines`). Install FlatCAM once; each project just points to it.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
@@ -21,37 +23,39 @@ Automates the conversion of a KiCad v9 `F.Paste` and `B.Paste` Gerber to G-code
|
|||||||
sudo apt install python3-venv python3-pip libgeos-dev libspatialindex-dev libxcb-cursor0
|
sudo apt install python3-venv python3-pip libgeos-dev libspatialindex-dev libxcb-cursor0
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Clone FlatCAM beta 8.995
|
### 2. Install FlatCAM beta 8.995 (shared, once)
|
||||||
|
|
||||||
|
If `~/flatcam-beta` already exists, skip to step 3 — there's nothing to do here.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone --branch mstanciu_Beta_8.995 --depth 1 https://github.com/dwrobel/flatcam.git flatcam-beta
|
git clone --branch mstanciu_Beta_8.995 --depth 1 https://github.com/dwrobel/flatcam.git ~/flatcam-beta
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Create a Python venv and install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd flatcam-beta
|
|
||||||
|
|
||||||
|
cd ~/flatcam-beta
|
||||||
python3 -m venv .flatcam-env
|
python3 -m venv .flatcam-env
|
||||||
source .flatcam-env/bin/activate
|
source .flatcam-env/bin/activate
|
||||||
|
|
||||||
pip install PyQt6 PyQt6-Qt6 PyQt6-sip
|
pip install PyQt6 PyQt6-Qt6 PyQt6-sip
|
||||||
|
|
||||||
# Skip ortools (path optimizer), rasterio, and gdal (image import) — not needed for stencils
|
# Skip ortools (path optimizer), rasterio, and gdal (image import) — not needed for stencils/outlines
|
||||||
grep -vE "ortools|rasterio|gdal" requirements.txt | pip install -r /dev/stdin
|
grep -vE "ortools|rasterio|gdal" requirements.txt | pip install -r /dev/stdin
|
||||||
|
|
||||||
|
deactivate
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Verify
|
### 3. Verify
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python flatcam.py --version
|
~/flatcam-beta/.flatcam-env/bin/python ~/flatcam-beta/flatcam.py --version
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see the FlatCAM version string printed without errors.
|
You should see the FlatCAM version string printed without errors.
|
||||||
|
|
||||||
Go back to the project directory:
|
### 4. Point this project at the shared install
|
||||||
|
|
||||||
|
`run_stencil.sh` reads the `FLATCAM_HOME` environment variable, defaulting to `~/flatcam-beta` if unset. Override it only if your install lives elsewhere:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ..
|
export FLATCAM_HOME=~/flatcam-beta # default, usually no need to set this
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. Export the stencil gerbers
|
### 5. Export the stencil gerbers
|
||||||
@@ -65,22 +69,41 @@ kicad-cli pcb export gerbers -o gerbers -l F.Paste,B.Paste ../kicad2panel/panel/
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Generate the stencil G-code for both layers:
|
Generate the stencil G-code for the layer `F.Paste`:
|
||||||
```bash
|
```bash
|
||||||
./run_stencil.sh gerbers/Flow_Controller_Panel-F_Paste.gtp \
|
./run_stencil.sh gerbers/Flow_Controller_Panel-F_Paste.gtp \
|
||||||
gcode/Flow_Controller_Panel-F_Paste-stencil.nc
|
gcode/Flow_Controller_Panel-F_Paste-stencil.nc
|
||||||
|
```
|
||||||
|
|
||||||
|
It should output:
|
||||||
|
|
||||||
|
```
|
||||||
|
→ Running FlatCAM headless...
|
||||||
|
Gerber : gerbers/Flow_Controller_Panel-F_Paste.gtp
|
||||||
|
Output : gcode/Flow_Controller_Panel-F_Paste-stencil.nc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
✓ Done: gcode/Flow_Controller_Panel-F_Paste-stencil.nc (277 lines)
|
||||||
|
```
|
||||||
|
|
||||||
|
Generate the stencil G-code for the layer `B.Paste`:
|
||||||
|
```bash
|
||||||
./run_stencil.sh gerbers/Flow_Controller_Panel-B_Paste.gbp \
|
./run_stencil.sh gerbers/Flow_Controller_Panel-B_Paste.gbp \
|
||||||
gcode/Flow_Controller_Panel-B_Paste-stencil.nc
|
gcode/Flow_Controller_Panel-B_Paste-stencil.nc
|
||||||
```
|
```
|
||||||
|
|
||||||
G-code for both layers should be in:
|
It should output:
|
||||||
|
|
||||||
```
|
```
|
||||||
gcode/Flow_Controller_Panel-F_Paste-stencil.nc
|
→ Running FlatCAM headless...
|
||||||
gcode/Flow_Controller_Panel-B_Paste-stencil.nc
|
Gerber : gerbers/Flow_Controller_Panel-B_Paste.gbp
|
||||||
```
|
Output : gcode/Flow_Controller_Panel-B_Paste-stencil.nc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
✓ Done: gcode/Flow_Controller_Panel-B_Paste-stencil.nc (1895 lines)
|
||||||
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@@ -129,10 +152,10 @@ Alternative: `GRBL_11_no_M6` suppresses tool change commands — not needed for
|
|||||||
The `run_stencil.sh` wrapper detects the `TclCommandQuit` log line and kills the process after 3 seconds. This is expected behavior — FlatCAM's Qt GUI cleanup hangs in headless mode.
|
The `run_stencil.sh` wrapper detects the `TclCommandQuit` log line and kills the process after 3 seconds. This is expected behavior — FlatCAM's Qt GUI cleanup hangs in headless mode.
|
||||||
|
|
||||||
**`ImportError: cannot import name 'Inf' from numpy`**
|
**`ImportError: cannot import name 'Inf' from numpy`**
|
||||||
You have the old PyPI FlatCAM 8.5 installed. Follow the installation steps above to switch to the beta 8.995 clone.
|
You have the old PyPI FlatCAM 8.5 installed somewhere on your `PATH`/venv. Make sure `FLATCAM_HOME` points at `~/flatcam-beta` (the beta 8.995 clone from the install steps above), not a pip-installed FlatCAM.
|
||||||
|
|
||||||
**`ImportError: cannot import name 'cascaded_union' from shapely.ops`**
|
**`ImportError: cannot import name 'cascaded_union' from shapely.ops`**
|
||||||
Same cause — old FlatCAM 8.5 is incompatible with Shapely 2.0. Switch to beta 8.995.
|
Same cause — old FlatCAM 8.5 is incompatible with Shapely 2.0. Check `FLATCAM_HOME` as above.
|
||||||
|
|
||||||
**G-code cuts everything except the pads**
|
**G-code cuts everything except the pads**
|
||||||
You used `ncc` (non-copper clear) instead of `paint`. The correct command is `paint` — it pockets the pad polygons. `ncc` clears everything around them, which is the inverse.
|
You used `ncc` (non-copper clear) instead of `paint`. The correct command is `paint` — it pockets the pad polygons. `ncc` clears everything around them, which is the inverse.
|
||||||
@@ -141,4 +164,7 @@ You used `ncc` (non-copper clear) instead of `paint`. The correct command is `pa
|
|||||||
Skip it — `gdal` is only needed for the image import plugin. Use:
|
Skip it — `gdal` is only needed for the image import plugin. Use:
|
||||||
```bash
|
```bash
|
||||||
grep -vE "ortools|rasterio|gdal" requirements.txt | pip install -r /dev/stdin
|
grep -vE "ortools|rasterio|gdal" requirements.txt | pip install -r /dev/stdin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Multiple projects, which one owns the FlatCAM install?**
|
||||||
|
None of them — `~/flatcam-beta` is shared and project-agnostic. Install it once via any one project's instructions above; every other `kicad2*` project just needs `FLATCAM_HOME` set (or left at its default) to find it. Don't `git clone` a second copy per project.
|
||||||
@@ -11,8 +11,8 @@ OUTPUT="${2:?Usage: $0 <B_Paste.gbp> <output.nc>}"
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
TCL_SCRIPT="$SCRIPT_DIR/paste_stencil.tcl"
|
TCL_SCRIPT="$SCRIPT_DIR/paste_stencil.tcl"
|
||||||
|
|
||||||
FLATCAM_PY="$HOME/proj/kicad2stencil/flatcam-beta/flatcam.py"
|
FLATCAM_PY="$HOME/flatcam-beta/flatcam.py"
|
||||||
FLATCAM_ENV="$HOME/proj/kicad2stencil/.flatcam-env"
|
FLATCAM_ENV="$HOME/flatcam-beta/.flatcam-env"
|
||||||
|
|
||||||
if [ ! -f "$FLATCAM_PY" ]; then
|
if [ ! -f "$FLATCAM_PY" ]; then
|
||||||
echo "ERROR: flatcam.py not found at $FLATCAM_PY"
|
echo "ERROR: flatcam.py not found at $FLATCAM_PY"
|
||||||
|
|||||||
Reference in New Issue
Block a user