Local bridge between your own coding agent and FreeCAD. FreeCAD runs one macro, watches a workspace inbox/, executes submitted Python jobs, and stores structured results under out/. Screenshots and exports are opt-in.
This project does not include or run an AI agent inside FreeCAD. Use an external agent that can read and write local files, for example Codex, Claude Code, or a similar coding agent. The human starts FreeCAD and the macro; the external agent works from the generated workspace, writes model scripts, submits jobs, reads compact summaries, and iterates. Screenshots are for deliberate visual checkpoints.
Clone this repository. Do not set this repository as FreeCAD's macro folder.
Run the setup script once. It creates:
- a clean agent workspace, by default
~/FreeCADAgent - one FreeCAD macro wrapper,
freecad_agent.FCMacro
Point your external coding agent at the generated workspace. The workspace contains only the files the agent needs:
FreeCADAgent/
freecad_folder_watch_agent.FCMacro # bridge macro source
agent_submit.py # submits jobs to inbox/
agent_data.py # lists and cleans output data
AGENTS.md # operational runbook for agents
README.md # short user documentation
examples/ # tracked example models
models/ # local model scripts, git-ignored
inbox/ # incoming jobs
out/ # results by project/session
logs/ # macro log
From the cloned repository:
python3 setup_freecad_agent.pyThen open FreeCAD and run the generated macro:
Macro > Macros... > freecad_agent.FCMacro > Execute
Keep FreeCAD open while the agent works. After changing or updating freecad_folder_watch_agent.FCMacro, run freecad_agent.FCMacro again in FreeCAD so the running bridge reloads the new code.
Custom workspace:
python3 setup_freecad_agent.py --workspace /path/to/FreeCADAgentOpen your external coding agent in the generated workspace, or tell it that this workspace is the working directory for the FreeCAD bridge. Then tell it to read AGENTS.md first. That file is the operational runbook: when to ask the user, how to choose project/session names, when jobs may be submitted, and how results should be checked.
Short flow:
- User starts FreeCAD and runs
freecad_agent.FCMacro. - User starts their own file-capable coding agent in the generated workspace.
- Agent establishes a project and session, for example
smart-convert-caseanddefaultorexploded. - Agent stores local model scripts under
models/. - Agent submits jobs with
agent_submit.py. - Agent reads the current state from
out/projects/<project>/sessions/<session>/current/.
Example:
python3 agent_submit.py models/model.py \
--project smart-convert-case \
--session default \
--title first-pass \
--no-fcstd \
--quietImportant outputs:
out/projects/<project>/sessions/<session>/current/result.json
out/projects/<project>/sessions/<session>/current/result_summary.json
out/projects/<project>/sessions/<session>/current/views/iso.png # when screenshots were requested
out/projects/<project>/sessions/<session>/runs/
For routine iteration, have the agent inspect the compact summary first:
python3 agent_data.py show --project smart-convert-case --session default --briefUse screenshots, full result.json, and exports when the compact summary is not enough to make the next modeling decision, or when you want a deliberate visual checkpoint.
A project is the overall model or task. A session is one view, variant, or work direction inside that project.
Example:
project: smart-convert-case
sessions:
default # assembled model
exploded # exploded view
Jobs with the same project/session pair reuse the same FreeCAD agent document. Different sessions stay separate.
Inspect stored data:
python3 agent_data.py list
python3 agent_data.py stats
python3 agent_data.py show --project smart-convert-case --session default --brief
python3 agent_data.py show --project smart-convert-case --session defaultCleanup commands are dry-runs by default:
python3 agent_data.py prune --project smart-convert-case --session default --keep-runs 20
python3 agent_data.py compact --older-than 14d --keep-runs 10Add --apply to actually delete files:
python3 agent_data.py prune --project smart-convert-case --session default --keep-runs 20 --apply--project NAME: project folder and part of the FreeCAD session identity.--session NAME: reused session inside a project.--mode rebuild|update:rebuildstarts fresh,updatekeeps existing objects.--views iso,front,right,top,bottom: screenshots to render. Defaults to no screenshots; use--views noneto skip explicitly.--param KEY=VALUE: pass one parameter to the model script.--params-file PATH: pass parameters from a JSON file.--step: export STEP.--stl: export STL.--3mf: export 3MF.--no-fcstd: do not save a FreeCAD file.
For low-cost design iteration, skip screenshots and the .FCStd checkpoint:
python3 agent_submit.py models/model.py \
--project smart-convert-case \
--session default \
--no-fcstd \
--quietRequest one smaller screenshot only when visual inspection is useful:
python3 agent_submit.py models/model.py \
--project smart-convert-case \
--session default \
--views iso \
--width 900 \
--height 700 \
--no-fcstd \
--quietRun a full checkpoint with multiple views and exports before user review, handoff, or manufacturing export.
Concrete local project models belong in models/; this folder is intentionally not tracked. Tracked, generally useful examples belong in examples/.