diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_ObjectFactory.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_ObjectFactory.cpp index 345ec0d9..ff2766ef 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_ObjectFactory.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_ObjectFactory.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using sofa::core::ObjectFactory; namespace py { using namespace pybind11; } @@ -221,6 +222,10 @@ void moduleAddObjectFactory(py::module &m) { factory.def_property_readonly_static("targets", [](const py::object &){ return getTargets(*ObjectFactory::getInstance()); }, doc::objectmodel::ObjectFactory_targets); + + factory.def_static("dump_json", [](){ + return sofa::core::ObjectFactoryJson::dump(ObjectFactory::getInstance()); + }, doc::objectmodel::ObjectFactory_targets); } } /// namespace sofapython3 diff --git a/bindings/Sofa/tests/Core/ObjectFactory.py b/bindings/Sofa/tests/Core/ObjectFactory.py new file mode 100644 index 00000000..12f0a155 --- /dev/null +++ b/bindings/Sofa/tests/Core/ObjectFactory.py @@ -0,0 +1,9 @@ +import unittest +import Sofa + +class Test(unittest.TestCase): + + def test_dump_json(self): + + json = Sofa.Core.ObjectFactory.dump_json() + self.assertIn("MechanicalObject", json, "MechanicalObject is not found in the json dump of the ObjectFactory")