# -*- coding: utf-8 -*-
# FreeCAD Macro: MyMacro
# Description: Brief description of what the macro does
# Author: YourName
# Version: 1.0
# Date: 2026-04-07
import FreeCAD
import Part
from FreeCAD import Base
if FreeCAD.GuiUp:
import FreeCADGui
from PySide2 import QtWidgets, QtCore
def main():
doc = FreeCAD.ActiveDocument
if doc is None:
FreeCAD.Console.PrintError("No active document
")
return
if FreeCAD.GuiUp:
sel = FreeCADGui.Selection.getSelection()
if not sel:
FreeCAD.Console.PrintWarning("No objects selected
")
doc.recompute()
FreeCAD.Console.PrintMessage("Macro completed
")
if __name__ == "__main__":
main()
Selection and console APIs to preserve:
sel = FreeCADGui.Selection.getSelection()
sel_ex = FreeCADGui.Selection.getSelectionEx()
for selobj in sel_ex:
obj = selobj.Object
for sub in selobj.SubElementNames:
shape = obj.getSubObject(sub)
FreeCADGui.Selection.addSelection(doc.MyBox)
FreeCADGui.Selection.addSelection(doc.MyBox, "Face1")
FreeCADGui.Selection.clearSelection()
FreeCAD.Console.PrintMessage("Info message
")
FreeCAD.Console.PrintWarning("Warning message
")
FreeCAD.Console.PrintError("Error message
")
FreeCAD.Console.PrintLog("Debug/log message
")
Compensation rules
User shorthand
FreeCAD API action
box
Part.makeBox()
cylinder
Part.makeCylinder()
sphere
Part.makeSphere()
merge, combine, join
.fuse()
subtract, cut, remove
.cut()
intersect
.common()
round edges, fillet
.makeFillet()
bevel, chamfer
.makeChamfer()
no document specified
doc = FreeCAD.ActiveDocument or FreeCAD.newDocument()
no units specified
assume millimeters
quick display
Part.show(shape, "Name")
persistent named object
doc.addObject("Part::Feature", "Name")
Always call doc.recompute() after modifications.
Progressive disclosure and bundled resources
references/freecad-implementation-patterns.md: detailed FreeCAD API concepts, FeaturePython, GUI, Coin3D, workbench, and reusable patterns.
references/scripting-fundamentals.md: document model, console, and core scripting.
references/geometry-and-shapes.md: Part, Mesh, Sketcher, and topology.
references/parametric-objects.md: FeaturePython, properties, and scripted objects.
references/gui-and-interface.md: PySide, dialogs, task panels, and Coin3D.
references/workbenches-and-advanced.md: workbenches, macros, FEM, Path, and recipes.
Compatibility vocabulary
Preserve these legacy terms, API names, command placeholders, and literal phrases when applying or migrating this skill:
PySide/Qt
bevel/chamfer
built-in
edges/fillet
merge/combine/join
quasi-code
sub-elements
sub-shape
subtract/cut/remove
topic-organized
Output template
## FreeCAD script result
**Status:** script-created | guidance-only | blocked
**Runtime:** FreeCAD Python macro | console snippet | workbench command
### Files or code
- `<path or snippet>`: <purpose>
### API coverage
| Area | APIs used | Notes |
| --- | --- | --- |
| Document | `FreeCAD.ActiveDocument`, `doc.recompute()` | <notes> |
| Geometry | `Part.makeBox()` / other APIs | <notes> |
| GUI | `FreeCAD.GuiUp` / PySide / selection | <notes> |
### Validation
- <how to run in FreeCAD and expected result>
Quality gate
The script imports only FreeCAD modules needed for the task.
GUI-dependent code is guarded with if FreeCAD.GuiUp:.
Document creation, object naming, and doc.recompute() are handled.
Units default to millimeters unless the user specified otherwise.
Geometry operations use the correct Part, Mesh, Sketcher, Draft, Arch, Path, FEM, TechDraw, BOPTools, or CompoundTools APIs.
Console messages use FreeCAD.Console.PrintMessage, PrintWarning, PrintError, or PrintLog.
Bundled references are used for FeaturePython, GUI, Coin3D, workbench, or advanced patterns when needed.
Run npx skillmds@latest add paulasilvatech/freecad-scripts in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Write FreeCAD Python scripts, macros, parametric FeaturePython objects, Part/Mesh/Sketcher geometry, PySide GUI tools, Coin3D/Pivy scenegraph code, workbench commands, and CAD automation. Use when asked to create FreeCAD models, automate geometry, convert mesh and solid data, script FEM/Path/TechDraw, or debug FreeCAD Python API tasks. It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
paulasilvatech (@paulasilvatech) published this skill. Their other Agent Skills are listed on their SkillMD profile.