Just now the new Extension mechanism has been merged into FreeCAD. It has been discussed here
, documentation for developer can be found in the source code of ExtensionContaienr
It opens up new possibilities for coding in FreeCAD and hence I like to introduce the new concept here. An extension is a FreeCAD Object much like every other, it has properties and methods. The difference: An extension is not used itself as object, but it is "added" to annother FreeCAD object. Than all properties and methods of the Extension become part of the extended object in a natural and intuitive manner.
What does that mean? For example now Groups are an extension. So everthing can become a group. If you want to make a Part::Feature also behave like a group just add the Group Extension to it, and than your new Type exposes a "Shape" property as well as a "Group" property. This works from c++ and python.
How does that change FreeCAD coding?
1. This allows to not only use linear inheritance as of now. With extensions Objects can implement multiple interfaces. So if you like to provide a interface of some kind which may be usefull for many objects just make it an extension!
2. It allows to create interfaces that can be used and overridden in other workbenches you do know nothing about. For example one could think that the Drawing workbench implements an Extension "Drawable" which does the Object specific drawing. Than Part::Feature would use that extensions and does the specific drawing, Mesh would do it also, and everyone that wants to have its objects on a drawing just uses the extension and overrides the methods. You see where this is going to: It reverses the Workbench dependencies: Now your workbench muust not include Part and Mesh, but Part and Mesh can include yours. That gives much flexibility.
Extensions can only be created in c++, but are usable and overridable from Python and c++. Most likely we will find missing things in the code when implementing new extensions, but we are free to extend the Extension implementation, just start a discussion about it!
I hope you all find it usefull