In FreeCAD, Python code can be used to create various elements programmatically, without needing the graphical user interface. Additionally, many tools and workbenches of FreeCAD are programmed in Python.
When writing Python code, it's advisable to follow PEP8: Style Guide for Python Code.
In this wiki, some conventions for Python examples should be followed.
This is a typical function
Wire = makeWire(pointslist, closed=False, placement=None, face=None, support=None)
- Python indicates optional arguments by providing a default value with key-value pairs. This means that any of the following calls are valid
Wire = makeWire(pointslist) Wire = makeWire(pointslist, False) Wire = makeWire(pointslist, False, None) Wire = makeWire(pointslist, False, None, None) Wire = makeWire(pointslist, False, None, None, None)
- The arguments
import FreeCAD, Draft
In particular, parentheses should immediately follow the function name, and a space should follow a comma. This makes the code more readable.