Docs menu: Recipes

Docs › Command line › Recipes

Recipes

Short, tested command sequences for common jobs. They assume nativecam-cli is on your PATH (see building and running) and a zsh or bash shell.

Post a folder of projects

Post every project in the current folder, keep each one's messages in a log, and list the ones that failed their checks:

$ for f in *.nativecam; do nativecam-cli post "$f" > "${f%.nativecam}.log" 2>&1 || echo "FAILED: $f"; done

Each project's G-code lands next to it with the controller's extension. A project that fails its checks writes no G-code, so the FAILED lines are the ones to open in the app.

Check projects in CI

post exits with status 1 when a project's G-code fails its checks, so a CI job only needs to post each project and let a failure stop the build. On a macOS runner with the Swift 6 toolchain, from a checkout of the NativeCAM repository:

set -e
swift build -c release --product nativecam-cli
CLI=.build/release/nativecam-cli
mkdir -p out
for f in path/to/projects/*.nativecam; do
  "$CLI" post "$f" -o "out/$(basename "${f%.nativecam}")"
done

Warnings don't fail the job; to be stricter, also fail on any [warning] line in the output.

Check G-code from another CAM program

Simulate the file, look at the picture, and check for rapids through material before it reaches the machine:

$ nativecam-cli sim job-from-vcarve.nc --png check.png
$ open check.png
if nativecam-cli sim job.nc | grep -q "rapid move(s) cut through material"; then
  echo "Rapids cut through material: don't run this file"
fi

The command line simulates on a new project's 24 × 18 × ¾ inch sheet with NativeCAM's starter bits. To use your own material and tool library, open the file in the app with File ▸ Simulate G-code File… (tutorial).

Compare two versions of a job

To see whether a change to a project, a post or NativeCAM itself changed the finished part, simulate both versions on the same grid and compare the heightmaps inside the part with the repository's scripts/measure/compare_parts.py:

$ nativecam-cli sim before.tap --cell 0.25 --heights before.bin
$ nativecam-cli sim after.tap --cell 0.25 --heights after.bin
$ python3 scripts/measure/compare_parts.py before.bin after.bin --rect 22 22 588 435
part cells: 2096715, differing > 0.005 in: 315167 (15.03%)
max extra material left: 0.7700 in, max extra cut: 0.0000 in
  • --rect x0 y0 x1 y1 or --ellipse cx cy rx ry marks the part, in millimetres from the material's lower-left corner. Only cells inside it count.
  • It reports how many part cells differ by more than 0.005 inch (0.127 mm), and the largest difference each way.
  • Both files must use the same grid: the same material and the same --cell. The grid size is capped, so a very small cell on large material is enlarged (0.25 mm on the 24 × 18 inch sheet comes out at 0.33 mm); both runs are enlarged the same way.

In the example, after is the demo sign's air cut, so it cuts nothing and the comparison reports the full depth of every cut as material left. A real change shows much smaller numbers.

Set up a machine from its settings

Start an empty project, write your controller's real limits into it, and post the acceptance test for exactly that machine:

$ nativecam-cli new my-machine.nativecam
$ nativecam-cli machine grbl-settings.txt --apply my-machine.nativecam
$ nativecam-cli acceptance my-machine.nativecam -o my-machine-test

A Grbl $ dump makes it a Grbl machine with no sender named, so the test comes out as one file per tool (my-machine-test 1 of 3 - T1.nc and so on). If your sender pauses on M6, add --controller grbl --sender gSender to keep it in one file, or name the sender in the app first. Open my-machine.nativecam in the app to check the result and save it to your machine library, then run the test as described in acceptance.

Convert a vendor tool library

$ nativecam-cli tools vendor-library.vtdb -o vendor-tools.json

Read the summary for skipped bits and estimated values, then import vendor-tools.json (or the original file) in the app's Tool Library and check the bits marked ⚠ before cutting.