Share

Node Parent / Child Relationships

Nodes in 3ds Max can be linked to one another to form parent / child hierarchies. This is also called node linking. The 3ds Max SDK provides a developer with methods to work with this hierarchy via the INode class. A node that is linked to another node is referred to as a child node. A node that has children is referred to as a parent node. A node may have several children, but only a single parent.

Developers can manipulate the hierarchy using methods INode::AttachChild(), INode::Detach(), and INode::GetParentNode(). One can check if a node is linked using INode::GetParentNode(). If the returned node is the root node (i.e. the function INode::IsRootNode() returns true) then the first node is not linked. The following sample function shows how to check this:

bool IsNodeLinked(INode* node) 
{
    return node->GetParentNode()  != NULL  && !node->GetParentNode()->IsRootNode();
}

-   `INode::AttachChild()` - Adds a child / parent relationship. The parent will receive the reference message `REFMSG_NODE_LINK`.
-   `INode::Detach()` - Removes a child / parent relationship. The parent will receive the reference message `REFMSG_NODE_LINK`.
-   `INode::NumberOfChildren()` - used to retrieve the number of children a node has.
-   `INode::GetParentNode()` - Returns the parent node of a child.
-   `INode::IsRootNode()` - determines if a node is a root node (does not have a parent node).
-   `INode::GetChildNode()` - returns an `INode` pointer to the nth child.

Was this information helpful?