[last updated: 2019-12-15]
FreeCAD
Macros
Scripting Investigations
(link to:) FreeCAD - Python tutorial
(link to:) FreeCAD - scripting examples
(link to:) FreeCAD - pyCollada for .dae files
-----
- Internal programming/operation of FreeCAD is done in Python (as well as C++). This means that you can use Python to execute actions in FreeCAD, including creating and editing drawings/models.
- Every action* on the FreeCAD GUI executes a Python code
You can watch what is happening on the Python Console. That is,
when you do something on the GUI (click a button or whatever),
the actual python command that is being executed will be shown in the Python Console.
In addition, you can type Python commands into the Console,
and when you press Enter, they will be executed.
*Note: except actions that "parametize the GUI itself"
- Show Python console:
Edit (top menu bar) > Preferences > Output window (tab)
under Python interpreter:
select: Redirect internal Python output to report view
select: Redirect internal Python errors to report view
<OK> at bottom
View (top menu bar) > Panels > Report View
View (top menu bar) > Panels > Python console
Tip: When the views get cluttered,
right-click --> Clear
- 3 ways to Execute Python commands:
- from Python console:
simply type in your command after the "> > > " prompt and it will be executed when you press Enter.
- from Macros:
- Execute external scripts:
external scripts must have a .py extension
in Python console, execute:
execfile("your_path_to_script")
However... so far I have not been able to make this work
.
.
.
eof