On Linux it is usually /home//.local/share/FreeCAD/Macro/ ( version 0.20 and above) or /home//.FreeCAD/Macro/ ( version 0.19 and below).If you don't know where the FreeCAD Macro folder is type FreeCAD.getUserMacroDir(True) in FreeCAD's Python console: But if you have another idea in mind, feel free to use that instead.
For the purposes of this tutorial, we're going to use the FreeCAD user Macro folder. That means you need to place them in a path that exists in your Python environment (or add it specifically).
But since the script module path is stored in the document, a user need only install the custom Python class code as an importable module, following the same folder structure, to regain the lost functionality.įeaturePython Object classes need to act as importable modules in FreeCAD. Only the FeaturePython object itself is saved (serialized). When working with custom classes and FeaturePython objects it is important to know that the custom class and its state are not saved in the document as this would require embedding a script in a FreeCAD document file, which would pose a significant security risk. In addition the Python class may implement certain methods to enable the object to respond to document events, making it possible to trap object property changes and document recomputes. For example, the Python class may add properties to the object or link it to other objects. This custom Python class takes a reference to one of these objects and modifies it. Some of them have "FeaturePython" alternatives that allow for customization with a user defined Python class. On this page we are going to construct a working example of a FeaturePython custom class, identifying all the major components and gaining an understanding of how everything works as we go along.įreeCAD comes with a number of default object types for managing different kinds of geometry.
Creative freedom to adapt FreeCAD for any task.Saving and restoring data (also known as serialization) through App::Property objects, without embedding any script in the FreeCAD document file.Rapid prototyping of new objects and tools with custom Python classes.FeaturePython objects (also referred to as Scripted objects) provide the ability to extend FreeCAD with objects that integrate seamlessly into the FreeCAD framework.