How to use GetChildren() in c++?
-
In python, I can op.GetChildren() easily.
But in c++, GetChildren() is under the
MAXON_METHOD.
Because I'm the new to c++, I can not understand the such complex grammar and the usage of this function in c++.
.
Please tell me how to get children of an object by using this function in c++. -
Hey @LingZA,
GelistNode.GetChildren
is a convenience function of the Python API which does not exist in the C++ API. You are looking there atHierarchyObjectInterface::GetChildren
which is an entirely different entity and method.To learn the basics about (classic API) node iteration in C++, I would recommend our GeListNode Manual. I also provided below a small code snippet explaining
GeListNode
child-iteration in C++.Cheers,
FerdinandCode:
// The object over whose children we want to loop. BaseObject* const parent; // Iterate over all children with a for-loop. for (BaseObject* child = parent->GetDown(); child; child = child->GetNext()) { ApplicationOutput("Child: @", child->GetName()); } // The C++ for-loop syntax can be a bit overwhelming for beginners. We can use also a while loop, // which is less elegant (while loops are scary), but it might be more obvious for people coming // from Python what is going on here: We loop over all children of a node until child.GetNext() is // the nullptr, i.e., more or less what is `None` in Python. BaseObject* child = parent->GetDown(); while (child) { ApplicationOutput("Child: @", child->GetName()); child = child->GetNext(); }
-
@ferdinand
That is great! Thanks!