GetChildren() in Cinema 4D SDK

For some reason Maxon’s Cinema 4D C++ SDK does not contain a GetChildren() function (whereas the Python SDK does have one). It’s not the hardest thing in the world to write yourself, but you have to do it nontheless. So here’s a simple template…

maxon::BaseArray children;

void MyApp::GetChildren(BaseObject* root) {
    BaseObject* child = root->GetDown();
    if (child == nullptr)
         return;
    while (child != nullptr) {
        children.Append(child);
         GetChildren(child);
         child = child->GetNext();
     }
}

children is a global variable in this case, but could of course just as well be passed to the function as a pointer…

Leave a Reply

Your email address will not be published. Required fields are marked *