Skip to main content

image

Overview

oc-freecad-cam exposes FreeCAD's Path workbench in a fluent python API that takes OCP TopoDS_Shape objects and their wrappers from CadQuery and Build123d to enable generating parametric tool paths from the comfort of your keyboard.

image

⚠ NOTE ⚠

This project is fairly experimental at this stage. Expect bugs and always double-check the generated gcode for naughty surprises.

Usage

See documentation at https://ocp-freecad-cam.readthedocs.io/en/latest/

Installation

ocp-freecad-cam is available on pypi: https://pypi.org/project/ocp-freecad-cam/ ocp-freecad-cam does not attempt to install runtime dependencies since it's designed to run with any combination of these three:

Additionally, FreeCAD module needs to be available.

General guideline for hooking on FreeCAD

There are at least three options to approach this

  1. Using the FreeCAD Python interpreter
  2. Using system interpreter with the same major version as the FreeCAD Python interpreter
  3. Compiling FreeCAD to use the system interpreter

Number one is now the recommended way and will be documented below

Acquiring FreeCAD and supported versions

FreeCAD version FreeCAD Python version ocp-freecad-cam version ocp-freecad-cam status
weekly 3.11 - work in progress
1.1.1 3.11 v2.0.0 ✅ dev
1.0.1 - 1.0.2 3.11 v1.1.0 ❌ EOL
0.21 3.10 v0.9.4 ❌ EOL
  1. Official distributions https://www.freecad.org/downloads.php
  2. Official portable packages https://github.com/FreeCAD/FreeCAD/releases
    • includes weekly packages

Linux AppImage installation example using a venv

This is fairly straightforward. Download the AppImage, extract it, create a virtual environment from the included interpreter, include lib, activate it and install your preferred packages.

mkdir freecad
cd freecad
wget https://github.com/voneiden/FreeCAD-Bundle/releases/download/0.21.2/FreeCAD_0.21.2-2023-12-26-conda-Linux-x86_64-py311.AppImage
chmod +x FreeCAD_0.21.2-2023-12-26-conda-Linux-x86_64-py311.AppImage
./FreeCAD_0.21.2-2023-12-26-conda-Linux-x86_64-py311.AppImage --appimage-extract
./squashfs-root/usr/bin/python -m venv --system-site-packages fcvenv
echo "$PWD/squashfs-root/usr/lib" > fcvenv/lib/python3.11/site-packages/freecad.pth
source fcvenv/bin/activate
pip install cadquery build123d ocp-freecad-cam

Test that your interpreter works by running

python -c "import FreeCAD"

Windows 7z installation example

While I would suggest using WLS, if you want to stick to pure windows, the general idea is the same as above in the linux example with two exceptions.

  1. Instead of "$PWD/squashfs-root/usr/lib" > fcvenv/lib/python3.11/site-packages/freecad.pth use
"$($PWD)\..\src" | Out-File -FilePath "fcvenv\Lib\site-packages\ocp_freecad_cam.pth"

or create the pth file manually somehow. Just note that the venv file structure is a bit different on Windows.

  1. Instead of source you activate the venv with just
.\fcvenv\Scripts\activate

Dev dependencies

Dev dependencies are listed in requirements-dev.txt, generated from requirements-dev.in with pip-compile

Limitations

Pocket3D does not work, possibly related to https://github.com/FreeCAD/FreeCAD/issues/6815 - shouldn't be a big loss though, Surface3D can get the same things done IMO.

VCarve can produce unstable toolpaths, but that is probably a bug in the underlying openvoronoi library. Tweaking the job params may help.

Contributing

Contributions are welcome.

  • Missing params, fixes
  • Tests
  • Documentation

Development Setup (Optional)

You can optionally use pre-commit hooks to automatically check your code before committing:

pip install pre-commit
pre-commit install

This will run ruff formatting, linting, and commitlint checks on your changes.

PR's

Format and lint your code with ruff and ensure that tests pass. Preferably also include test coverage for new code.

ruff format src tests
ruff check src tests
pytest

Commit messages should follow Conventional Commits format.

Release files for ocp-freecad-cam 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocp-freecad-cam 2.0.2
File Size Uploaded
ocp_freecad_cam-2.0.2.tar.gz 158.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ocp-freecad-cam 2.0.2
File Interpreter ABI Platform
ocp_freecad_cam-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 192.6 kB

Release files / ocp_freecad_cam-2.0.2.tar.gz

Download URL ocp_freecad_cam-2.0.2.tar.gz
Size 158.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bca55a82fccf05f0ef85b6060437a07b946e76f55c123768771dcea2d0f7bba6
BLAKE2b-256 checksum
How to use checksums
23e54a6e9b34710a73b049bdb88e81863f02e73f0ff1ae03fb43d3c5d8711ff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / ocp_freecad_cam-2.0.2-py3-none-any.whl

Download URL ocp_freecad_cam-2.0.2-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3878c9e0ad1111ae0db90426077c105d87b99a170139850bd33b9361f2302f3e
BLAKE2b-256 checksum
How to use checksums
8ac60647b95193c016d7dccc6a89b9d8de9e2263392fb2f89d6e90870b039d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page