Skip to content

Commit 3ec609c

Browse files
committed
Retrieve the target from a linkpath
1 parent c2886f6 commit 3ec609c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_LinkPath.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ using sofa::core::objectmodel::BaseLink;
2424
#include <sofa/core/objectmodel/BaseObject.h>
2525
using sofa::core::objectmodel::BaseObject;
2626

27+
#include <SofaPython3/PythonFactory.h>
28+
2729
#include <SofaPython3/Sofa/Core/Binding_LinkPath.h>
2830
#include <SofaPython3/Sofa/Core/Binding_LinkPath_doc.h>
2931

@@ -79,6 +81,13 @@ void moduleAddLinkPath(py::module& m)
7981
py::class_<LinkPath> link(m, "LinkPath", sofapython3::doc::linkpath::linkpath);
8082
link.def("__str__", &__str__);
8183
link.def("__repr__", &__repr__);
84+
link.def("target", [](const LinkPath& entry) -> py::object{
85+
if(entry.targetData != nullptr)
86+
return PythonFactory::toPython(entry.targetData);
87+
else if(entry.targetBase.get() != nullptr)
88+
return PythonFactory::toPython(entry.targetBase.get());
89+
return py::none();
90+
});
8291
}
8392

8493
}/// namespace sofapython3

0 commit comments

Comments
 (0)