Skip to content

Commit 5dd9eef

Browse files
committed
Add and "apply" méthod to node
1 parent 9de87d4 commit 5dd9eef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stlib/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
__all__ = ["core","entities","prefabs","shapes"]
22

33
import Sofa.Core
4+
5+
def __apply(self : Sofa.Core.Node, typeName, **kwargs):
6+
if not callable(typeName):
7+
raise Exception("Invalid parameter")
8+
return typeName(self, **kwargs)
9+
410
def __genericAdd(self : Sofa.Core.Node, typeName, **kwargs):
511
def findName(cname, names):
612
"""Compute a working unique name in the node"""
@@ -54,3 +60,4 @@ def findName(cname, names):
5460

5561
# Inject the method so it become available as if it was part of Sofa.Core.Node
5662
Sofa.Core.Node.add = __genericAdd
63+
Sofa.Core.Node.apply = __apply

0 commit comments

Comments
 (0)