This documentation is not finished. Please help and contribute documentation.
GuiCommand model explains how commands should be documented. Browse Category:UnfinishedDocu to see more incomplete pages like this one. See Category:Command Reference for all commands.
See WikiPages to learn about editing the wiki pages, and go to Help FreeCAD to learn about other ways in which you can contribute.
It becomes necessary at times to expand the FreeCAD API further by exposing functions that are available in the source code in c++ to the python. In so doing, providing an ability to trigger deep internal functionality with Python in real-time instead of needing to compile.
Below is an explanation of how one can achieve this.
The basic structure of a program to expose functionality to Python is something like this:
There are two source files required to implement a new Python binding. Assuming we wanted to expose some methods from FreeCAD/src/Mod/Part/TopoShape.cpp, we would need to make:
These 2 files need to be added to ../Mod/yourModule/App/CMakeLists.txt. See FreeCAD/src/Mod/Part/App/CMakeLists.txt for an example.
You can extend the Python version of your module by adding to ../Mod/yourModule/App/AppmyModulePy.cpp (see FreeCAD/src/Mod/Part/AppPartPy.cpp). The additions are accessed in Python by "import myModule".
Note: