OCP FreeCAD CAM
Project description
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.
⚠ 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
- Using the FreeCAD Python interpreter
- Using system interpreter with the same major version as the FreeCAD Python interpreter
- Compiling FreeCAD to use the system interpreter
Number one is now the recommended way and will be documented below
Acquiring FreeCAD
Two options. Please use at FreeCAD version 1.0.1 or greater. If for some reason you'd prefer to use an older version of FreeCAD (v0.21), see the v0.9.4 release of ocp-freecad-cam.
- Official distributions https://www.freecad.org/downloads.php
- 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.
- Instead of
"$PWD/squashfs-root/usr/lib" > fcvenv/lib/python3.11/site-packages/freecad.pthuse
"$($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.
- Instead of
sourceyou 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocp_freecad_cam-1.1.0.tar.gz.
File metadata
- Download URL: ocp_freecad_cam-1.1.0.tar.gz
- Upload date:
- Size: 155.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3487c411614a97c9f85e1fc6abb3b0ee90bf17820398742d24fa36b1f66baf10
|
|
| MD5 |
4ddd474489838f6e55776b8daf4a2a97
|
|
| BLAKE2b-256 |
7a38e9cd452057fa513b3663c0675aa7bef1e905bd9b6d474565b90dd1f01048
|
File details
Details for the file ocp_freecad_cam-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ocp_freecad_cam-1.1.0-py3-none-any.whl
- Upload date:
- Size: 32.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057ac9bc5b62539384675fd05d0327b6f0a665de23be40f51c7b99b2188b8bb0
|
|
| MD5 |
ab31be54171ef43cf243430013051879
|
|
| BLAKE2b-256 |
a0e600738e641bd7354237b9cb8881246af1e0520aa548fb8c40bd12c1449697
|