SofaPython3
SofaPython3 copied to clipboard
[POC] The Really Magic Require Plugin
The plugin scans the plugin reporitories to locate what are the Sofa plugins that match a given pattern. Once found it createe a hierarchy in the scene graph by splitting the "." in the names.
So now you can do stuff like
def createScene(root):
# Load everything about SolidMechanics
root.addChild(RequiredPlugin("Sofa.Component.SolidMechanics"))
# Load everything about Sofa.Component
root.addChild(RequiredPlugin("Sofa.Component"))
This is a WIP as some feature are badly implemented in python without changing anything in the sofa core.
Interesting idea 👏
Is it not already possible to do this?
# Load everything about Sofa.Component
root.addChild(RequiredPlugin("Sofa.Component"))
If no, I don't understand why. The plugin Sofa.Component
does exist.
@guparan
No, what we currently have is:
root.addChild("RequiredPlugin". "Sofa.Component")
Which is loading a single "special" plugin targets that loads other. To make that happens, we have hardcoded, for every intermediate level of the hierarchy, to build such a target. This is far from satisfying as it is very invasive and it is only working if the /plugin/module's supplier has modified it CMakeList.txt to build every target. The existing mecanism also does not provide any feedback on what is actually "imported" from Sofa.Component and will not work for anything other than the hardcoded targets.
This POC shows that a similar feature can be implemented in a non-invasive way, without the need for harcoded extra target (saving writing and compiling them in CMakeLists.txt for all the intermediate targets). It also provide an interesting graphical feedback so the users knows what is actually loaded which has a lot of side effects (among which better learning curve for user to discover the sub-packages).
Another POC could be to implement the same thing in c++ so it would also work the same for XML.