Skip to content

Repository files navigation

FreeCAD Addon Template

CookieCutter template for generating FreeCAD addon boilerplate.

Note

You do not need to fork this template to use it, just follow the "Quick Start" instructions below.

Important

Everything generated by this cookiecutter template is an example. Once the initial boilerplate is generated, modify/structure as you see fit.

Dependencies

Quick Start

Install uv

There are a couple of methods to install uv, look at the docs here: https://docs.astral.sh/uv/getting-started/installation/

The Typical install on POSIX platforms is:

curl -LsSf https://astral.sh/uv/install.sh | sh

You don't have to install cookiecutter or python by hand as uv will take care of that.

Create an addon

Launch cookiecutter and point it at the template repo:

uvx cookiecutter https://github.com/FreeCAD/Addon-Template.git --checkout cookie

Answer the questions:

  [1/13] Addon name (MyAddon):
  [2/13] Project directory (MyAddon):
  [3/13] Python sub-module name (MyAddon):
  [4/13] Name of the svg icon file (addon.svg):
  [5/13] Name of the author/maintainer (me):
  [6/13] Email of the author/maintainer (me@foobar.com):
  [7/13] Short description of the addon (MyAddon does something cool.):
  [8/13] Required pypi dependencies (optional, separated by comma. i.e. numpy,pillow) ():
  [9/13] Initial version using format major.minor.review (0.1.0):
  [10/13] Select addon_license
    1 - LGPL-2.1-or-later
    2 - LGPL-3.0-or-later
    3 - GPL-3.0-or-later
    4 - MIT
    5 - CC0
    6 - CC-BY-SA-4.0
    7 - OTHER
    Choose from [1/2/3/4/5/6/7] (1):
  [11/13] Select assets_license
    1 - CC-BY-SA-4.0
    2 - CC0
    3 - LGPL-2.1-or-later
    4 - LGPL-3.0-or-later
    5 - GPL-3.0-or-later
    6 - MIT
    7 - OTHER
    Choose from [1/2/3/4/5/6/7] (1):
  [12/13] Full url of the git repository (https://github.com/me/MyAddon):
  [13/13] Name of the default git branch (main):

Voila, the addon has been created in a directory under the current directory:

MyAddon/
├── freecad
│   └── MyAddon
│       ├── commands
│       │   ├── example_command.py
│       │   ├── example_manipulator.py
│       │   └── __init__.py
│       ├── example_workbench.py
│       ├── init_gui.py
│       ├── __init__.py
│       ├── resources
│       │   ├── docs
│       │   │   └── Overview.md
│       │   ├── icons
│       │   │   ├── MyAddon.svg
│       │   │   └── MyAddon-wb.svg
│       │   ├── __init__.py
│       │   ├── translations
│       │   │   ├── MyAddon_es-ES.ts
│       │   │   ├── README.md
│       │   │   └── update_translation.py
│       │   └── ui
│       └── version.py
├── LICENSE-Assets
├── LICENSE-Code
├── package.xml
├── pixi.toml
├── pyproject.toml
└── README.md

Install the addon

The easiest way to install a newly created addon is to just symlink it into the Mod directory if your platform allows symlinks.

# cd to the Mod directory of your FreeCAD installation
cd <FreeCAD user's config directory>/Mod
ln -s <path to the created addon> MyAddon

The other option is to just copy your addon dir into <FreeCAD user's config directory>/Mod

Typical User Mod Locations

Platform Typical Path
Windows %APPDATA%\FreeCAD\Mod\
*(Full path: C:\Users\<username>\AppData\Roaming\FreeCAD\Mod\) *
Linux v0.20+: ~/.local/share/FreeCAD/Mod/
v0.19 & older: ~/.FreeCAD/Mod/
macOS /Users/<username>/Library/Application Support/FreeCAD/Mod/

Important Platform-Specific Notes

  • Linux (Snap/Flatpak): If you installed FreeCAD via a sandboxed package manager, the directory will be different:
    • Snap: ~/snap/freecad/common/Mod/
    • Flatpak: ~/.var/app/org.freecad.FreeCAD/data/FreeCAD/Mod/

Pro-Tip: Find it via the Python Console

If you aren't sure where your specific installation is looking for files, you can find the exact path directly inside FreeCAD:

  1. Open FreeCAD.
  2. In the Python Console (View > Panels > Python Console), type the following and press Enter: App.getUserAppDataDir()
  3. The output will be the parent directory of your Mod folder.

Testing the addon without installing it

freecad -M <path to MyAddon>

For Installation into the AddonManager

See instructions here: https://freecad.github.io/Addon-Academy/

Contributors

Languages