一键导入
freecad-environment-setup
How to import FreeCAD Python modules from the AppImage when running agent scripts or standalone tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
How to import FreeCAD Python modules from the AppImage when running agent scripts or standalone tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Architecture reference for the unified edit-mode transform gizmo (translation arrows + rotation rings, transform spaces, x-ray rendering). Required reading before implementing any task in todo.md whose ID begins with GIZMO-.
Reference for the two-color (orange/blue) boolean system where IsSubtractive classifies inputs into groups and boolean operations combine them into a parent-child tree. Required reading before implementing any task in todo_bool.md.
Standardized pattern for creating interactive SDF primitive tools in the Direct Modeling workbench.
Template and rules for creating new SDF primitive field classes in core/sdf/sdf/. Required reading before implementing any new SdfField subclass.
Reference for converting SVG path data (M L H V C S Q T A Z) and shape elements (rect, circle, ellipse, line, polyline, polygon) into cubic Bezier segments with no rasterization. Required reading before implementing svg_importer.py.
Convention for registering primitive-specific GLSL inside the primitive's own .py file. Required reading before editing any to_glsl/to_glsl_2d method.
| name | FreeCAD Environment Setup |
| description | How to import FreeCAD Python modules from the AppImage when running agent scripts or standalone tests. |
FreeCAD is installed as an AppImage at:
/home/steve/Programs/Freecad/FreeCAD_weekly-2026.01.21-Linux-x86_64-py311.AppImage
Agents running Python scripts cannot import FreeCAD directly — the modules live inside the AppImage.
The AppImage bundles its own Python 3.11. Run scripts with it directly:
APPIMAGE=/home/steve/Programs/Freecad/FreeCAD_weekly-2026.01.21-Linux-x86_64-py311.AppImage
# Extract AppImage to a temp dir (one-time, ~10s):
"$APPIMAGE" --appimage-extract-and-run python3 your_script.py
# OR mount the squashfs and use the bundled python:
"$APPIMAGE" --appimage-mount &
MOUNT=$(ls -d /tmp/.mount_FreeCA* 2>/dev/null | tail -1)
"$MOUNT/usr/bin/python3" your_script.py
fusermount -u "$MOUNT"
Mount the AppImage, then prepend paths before importing:
import sys, subprocess, os
APPIMAGE = "/home/steve/Programs/Freecad/FreeCAD_weekly-2026.01.21-Linux-x86_64-py311.AppImage"
# Mount
proc = subprocess.Popen([APPIMAGE, "--appimage-mount"], stdout=subprocess.PIPE)
mount_point = proc.stdout.readline().decode().strip()
# Add FreeCAD Python paths
sys.path.insert(0, f"{mount_point}/usr/lib")
sys.path.insert(0, f"{mount_point}/usr/lib/python3/dist-packages")
sys.path.insert(0, f"{mount_point}/usr/lib/freecad/lib")
import FreeCAD # now works
# ... your code ...
proc.terminate()
For testing code that uses FreeCAD.Vector / FreeCAD.Base.Placement etc. without the GUI, use the stub at test_proj.py as a pattern — define a minimal Vector class locally and avoid importing the real module.
# At top of test file
import sys
from types import ModuleType
# Minimal FreeCAD stub
fc = ModuleType("FreeCAD")
class _Vec:
def __init__(self, x=0, y=0, z=0): self.x=x; self.y=y; self.z=z
fc.Vector = _Vec
sys.modules["FreeCAD"] = fc
# Now your DM code can be imported
from core.sdf.sdf.box import MCBoxField # works without real FreeCAD
/home/steve/Programs/Freecad/FreeCAD_weekly-2026.01.21-Linux-x86_64-py311.AppImage \
--appimage-extract-and-run python3 --version
# Should print: Python 3.11.x