Skip to content

Commit

Permalink
Exposed Element.getChild() in the Python API docs. (#1567)
Browse files Browse the repository at this point in the history
...by renaming `Element._getChild()` to `Element.getChild()`.

Signed-off-by: Stefan Habel <19556655+StefanHabel@users.noreply.github.com>
  • Loading branch information
StefanHabel committed Oct 31, 2023
1 parent 939c996 commit 77b5944
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions python/MaterialX/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def _addChild(self, elementClass, name, typeString = ''):
method = getattr(self.__class__, "_addChild" + elementClass.__name__)
return method(self, name, typeString)

def _getChild(self, name):
"Return the child element, if any, with the given name."
if (name == None):
_Element_getChild = Element.getChild

def getChild(self, name):
if name is None:
return None
return self._getChild(name)
return _Element_getChild(self, name)

def _getChildOfType(self, elementClass, name):
"Return the child element, if any, with the given name and subclass."
Expand All @@ -54,7 +55,8 @@ def _removeChildOfType(self, elementClass, name):

Element.isA = _isA
Element.addChild = _addChild
Element.getChild = _getChild
Element.getChild = getChild
Element.getChild.__doc__ = _Element_getChild.__doc__
Element.getChildOfType = _getChildOfType
Element.getChildrenOfType = _getChildrenOfType
Element.removeChildOfType = _removeChildOfType
Expand Down
2 changes: 1 addition & 1 deletion source/PyMaterialX/PyMaterialXCore/PyElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void bindPyElement(py::module& mod)
)docstring"))

.def("changeChildCategory", &mx::Element::changeChildCategory)
.def("_getChild", &mx::Element::getChild)
.def("getChild", &mx::Element::getChild)
.def("getChildren", &mx::Element::getChildren)
.def("setChildIndex", &mx::Element::setChildIndex)
.def("getChildIndex", &mx::Element::getChildIndex)
Expand Down

0 comments on commit 77b5944

Please sign in to comment.