FreeCAD Developer Skill
This skill guides AI agents in navigating, building, extending, and debugging the core C++ and hybrid Python architecture of FreeCAD.
Based on the official FreeCAD Documentation: Developers hub.
FreeCAD Source Architecture Overview
FreeCAD is organized as a layered modular system:
FreeCAD Core Source Tree (`src/`):
├── Base/ # Fundamental abstractions: Vectors, Matrices, Units, Exceptions, XML parser, Logging
├── App/ # Core document model: PropertyContainer, Document, DocumentObject, Transactions (No GUI)
├── Gui/ # Presentation layer: Qt Widgets, 3D Coin3D Viewer, Selection, ViewProviders, Commands
└── Mod/ # Domain modules / Workbenches (Part, PartDesign, Sketcher, TechDraw, FEM, BIM, etc.)
├── Part/
│ ├── App/ # Part C++ backend (OCCT integration, Part::TopoShape, BRep algorithms)
│ └── Gui/ # Part GUI commands, ViewProviders, Qt dialogs
├── Sketcher/
│ ├── App/ # Sketcher C++ backend & PlaneGCS constraint solver
│ └── Gui/ # Sketcher interactive 2D solver editor & UI tools
└── ...
Key Development Workflows
1. Compiling FreeCAD with CMake
Standard build instructions across Linux, macOS, and Windows:
# 1. Clone repository
git clone --recurse-submodules https://github.com/FreeCAD/FreeCAD.git freecad-source
# 2. Configure build directory
mkdir build && cd build
cmake ../freecad-source \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DFREECAD_USE_QT_FILEDIALOG=ON \
-DBUILD_ENABLE_CXX20=ON \
-DPYTHON_EXECUTABLE=$(which python3)
# 3. Compile
cmake --build . --parallel $(nproc)
# 4. Run tests
ctest --output-on-failure
2. Exposing C++ Classes to Python
FreeCAD uses XML definition templates and code generation scripts to generate C++ boilerplate for Python type wrappers:
FeaturePy.xml: Defines Python class name, docstrings, methods, and attributes.
- FreeCAD build tool runs
GenerateFeaturePy.py → produces FeaturePy.h and FeaturePyImp.cpp.
- Developer implements method logic in
FeaturePyImp.cpp.
3. Adding a New Workbench
Workbenches can be:
- Pure Python: Fast prototyping, dynamic loading via
Init.py and InitGui.py.
- Hybrid / C++: Performance-critical algorithms, OpenCASCADE kernel extensions, native Coin3D nodes.
Every workbench implements:
Init.py: Headless initialization (runs when FreeCAD starts without GUI).
InitGui.py: GUI workbench registration, workbench icon, menus, toolbars, and context menus.
Detailed References
Consult the following comprehensive guides in references/:
- Developer Handbook & Roadmap: Complete index of all 57 C++ source documentation guides, compilation options, architecture modules, and roadmap.
- Source Architecture & Modules: Deep breakdown of
Base, App, Gui, and Mod libraries.
- Compilation Guide: Building on Ubuntu/Debian, Fedora, Arch, Windows (MSVC/Conda), macOS, and Docker.
- C++ & Python Bindings: How to create XML templates and implement Python wrappers for C++ classes.
- New Workbench Creation: Step-by-step guide to writing pure Python and C++ workbenches.
- Sketcher Solver Internals: The PlaneGCS geometric constraint solver architecture and algorithm.
- Testing & Packaging: Running
FreeCADTest, writing unit tests, and packaging (AppImage, Conda, Flatpak).
Offline Documentation Search Tool
To query internal classes, build flags, solver details, or C++ API symbols across all 2,595+ documentation files:
python scripts/freecad_doc_query.py "<symbol_or_topic>"
Examples
1---2name: freecad-developer3description: >-4 C++ core development, source architecture, CMake compilation, C++ workbench creation,5 exposing C++ classes to Python (PyCXX/CPython XML templates), Sketcher PlaneGCS solver internals,6 testing (`App::UnitTest`), and packaging (Docker, Conda, AppImage, Windows/macOS) for FreeCAD.7 Use this skill whenever assisting with compiling FreeCAD from source, hacking or modifying8 FreeCAD's C++ codebase, creating native C++ workbenches, writing Python/C++ bindings,9 or troubleshooting low-level solver and build issues.10metadata:11 source: https://skillmd.com/skills/glotoff/freecad-developer12---1314# FreeCAD Developer Skill1516This skill guides AI agents in navigating, building, extending, and debugging the core C++ and hybrid Python architecture of FreeCAD.1718Based on the official [FreeCAD Documentation: Developers hub](https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Developer_hub.md).1920---2122## FreeCAD Source Architecture Overview2324FreeCAD is organized as a layered modular system:2526```27FreeCAD Core Source Tree (`src/`):28├── Base/ # Fundamental abstractions: Vectors, Matrices, Units, Exceptions, XML parser, Logging29├── App/ # Core document model: PropertyContainer, Document, DocumentObject, Transactions (No GUI)30├── Gui/ # Presentation layer: Qt Widgets, 3D Coin3D Viewer, Selection, ViewProviders, Commands31└── Mod/ # Domain modules / Workbenches (Part, PartDesign, Sketcher, TechDraw, FEM, BIM, etc.)32 ├── Part/33 │ ├── App/ # Part C++ backend (OCCT integration, Part::TopoShape, BRep algorithms)34 │ └── Gui/ # Part GUI commands, ViewProviders, Qt dialogs35 ├── Sketcher/36 │ ├── App/ # Sketcher C++ backend & PlaneGCS constraint solver37 │ └── Gui/ # Sketcher interactive 2D solver editor & UI tools38 └── ...39```4041---4243## Key Development Workflows4445### 1. Compiling FreeCAD with CMake4647Standard build instructions across Linux, macOS, and Windows:4849```bash50# 1. Clone repository51git clone --recurse-submodules https://github.com/FreeCAD/FreeCAD.git freecad-source5253# 2. Configure build directory54mkdir build && cd build55cmake ../freecad-source \56 -DCMAKE_BUILD_TYPE=RelWithDebInfo \57 -DFREECAD_USE_QT_FILEDIALOG=ON \58 -DBUILD_ENABLE_CXX20=ON \59 -DPYTHON_EXECUTABLE=$(which python3)6061# 3. Compile62cmake --build . --parallel $(nproc)6364# 4. Run tests65ctest --output-on-failure66```6768### 2. Exposing C++ Classes to Python6970FreeCAD uses XML definition templates and code generation scripts to generate C++ boilerplate for Python type wrappers:71- `FeaturePy.xml`: Defines Python class name, docstrings, methods, and attributes.72- FreeCAD build tool runs `GenerateFeaturePy.py` → produces `FeaturePy.h` and `FeaturePyImp.cpp`.73- Developer implements method logic in `FeaturePyImp.cpp`.7475### 3. Adding a New Workbench7677Workbenches can be:781. **Pure Python**: Fast prototyping, dynamic loading via `Init.py` and `InitGui.py`.792. **Hybrid / C++**: Performance-critical algorithms, OpenCASCADE kernel extensions, native Coin3D nodes.8081Every workbench implements:82- `Init.py`: Headless initialization (runs when FreeCAD starts without GUI).83- `InitGui.py`: GUI workbench registration, workbench icon, menus, toolbars, and context menus.8485---8687## Detailed References8889Consult the following comprehensive guides in `references/`:90- [Developer Handbook & Roadmap](./references/developer_handbook_and_roadmap.md): Complete index of all 57 C++ source documentation guides, compilation options, architecture modules, and roadmap.91- [Source Architecture & Modules](./references/source_architecture.md): Deep breakdown of `Base`, `App`, `Gui`, and `Mod` libraries.92- [Compilation Guide](./references/compilation_guide.md): Building on Ubuntu/Debian, Fedora, Arch, Windows (MSVC/Conda), macOS, and Docker.93- [C++ & Python Bindings](./references/cpp_python_bindings.md): How to create XML templates and implement Python wrappers for C++ classes.94- [New Workbench Creation](./references/new_workbench_creation.md): Step-by-step guide to writing pure Python and C++ workbenches.95- [Sketcher Solver Internals](./references/sketcher_solver.md): The PlaneGCS geometric constraint solver architecture and algorithm.96- [Testing & Packaging](./references/testing_and_ci.md): Running `FreeCADTest`, writing unit tests, and packaging (AppImage, Conda, Flatpak).9798### Offline Documentation Search Tool99To query internal classes, build flags, solver details, or C++ API symbols across all 2,595+ documentation files:100```bash101python scripts/freecad_doc_query.py "<symbol_or_topic>"102```103104## Examples105106- [dummy_workbench_template/](./examples/dummy_workbench_template/): Minimal, functional workbench boilerplate ready to drop into `~/.FreeCAD/Mod/` or `src/Mod/`.