I've updated Part-o-magic to work with Extension-powered containers. But more importantly, Part-o-magic now offers a new object container! I called it "Module". It's an analog of PartDesign Body, but made for Part workbench and any other wb that makes shapes (e.g. Draft, Lattice). This can also be an example of how does one make a python-powered container (see https://github.com/DeepSOIC/Part-o-magi ... /Module.py)
Install:
https://github.com/DeepSOIC/Part-o-magic
Use FreeCAD's built-in add-on manager (menu Tools->Addon manager).
After installing PoM, restart FreeCAD.
* Part-o-magic workbench should appear in workbench selector.
* A small global toolbar should appear, which you can disable or customize in Tools->Customize->Toolbars.
* Behavior of PartDesign workbench should change drastically, that is due to Observer running. Uninstall:
You can disable part-o-magic with buttons on the workbench. If you disable the workbench, all the automation stuff should switch off, but features of part-o-magic can still be recomputed in your projects that have them.
If you completely uninstall the workbench (delete Mod/Part-o-magic folder), part-o-magic features you used in your projects will stop working.
Important. Part-o-magic messes with "DisplayModeBody" properties of PartDesign Body objects, and "Selectable" properties of all objects. If you uninstall Part-o-magic, or disable its automation stuff, it will cause somewhat unusual behavior of any projects that were saved with part-o-magic enabled and had any container objects present. You can reset them manually with property editor, or run this simple snippet in Py console:
Code: Select all
for obj in App.ActiveDocument.Objects:
if hasattr(obj.ViewObject, "DisplayModeBody"):
obj.ViewObject.DisplayModeBody = "Through"
if hasattr(obj.ViewObject, "Selectable"):
obj.ViewObject.Selectable = True
Main features:
"Observer"
* Active container everywhere:
In PartDesign, all new features are automatically added to Body. Observer expands this to all workbenches of FreeCAD: new objects, made in any workbench, are automatically added to active container.
* Visibility automation:
when you activate a container, the container is switched into Through mode, so you see individual contained objects. When you leave it, you see only the final shape (Tip), but not contained objects. Also, when you activate a container, anything outside of it is automatically hidden, so that you can focus on editing the piece.
* Tree automation:
when you activate a container, it is automatically expanded in tree. When deactivated, it is automatically collapsed. With the aim to show you only the features that make up the container, so that you can focus on editing the piece.
Containers
* Module container
It's an analog of PartDesign Body, but for Part and other workbenches. It groups together features that were used to create a final shape, and exposes the final shape (Tip) as its own.
* ShapeGroup container
(similar to Module, but exposing multiple objects)
* PartDesign Additive shape, PartDesign Subtractive shape containers
These are Modules that pretend to be PartDesign features, allowing to integrate other workbench tools into PartDesign workflow. See tutorial post later in this thread.
Other features:
* tool for altering Tip
* buttons to enter and leave objects (can be used to enter/leave containers, and edit objects (e.g. open a sketch))
* button to create Part container
* button to create Shapebinders (works outside of PartDesign, too).
* Exporter feature, for keeping exported files up to date with project. See this post.
* buttons to disable Part-o-magic (there's a good chance part-o-magic will break soon). If disabled, Module containers should still work, albeit not very useful because they rely on part-o-magic's automatic object addition.
Limitations/ known bugs
* will be confused by Groups (probably; untested). This may soon be fixed... when visibility behavior of groups will be changed to match that of Parts
Future plans: (hahaha, things rarely go as planned)
* attachable version of Module, and integration with Lattice, to provide somewhat useful assembly capabilities
The overall goal of doing this was to get some sense of what it takes to create a python powered object container. As well as gain some insights to what interfaces are needed for implementing something like this in FreeCAD itself.