Navigating Node Graphs

Describes how to navigate a node graph. Contains topics on finding a specific node, iterating over ports or retrieving ancestors to find information.

Iterate over True Nodes

There are three functions to iterate over nodes:

Finding a Specific True Node

For nodes can be searched with their identifier, name or other types of data.

// Find nodes that have some value in common with the passed DataDictionary
maxon::DataDictionary dict;
dict.Set(maxon::NODE::BASE::COMMENT, "This is my comment"_s) iferr_return;
{
ApplicationOutput("this graph have the same data @", child);
return true;
static MAXON_METHOD Result< void > ListAllNodes(const GraphModelRef &graphModel, const DataDictionary &matchingData, const ValueReceiver< const GraphNode & > &callback)
PyObject PyObject * dict
Definition: abstract.h:150

Iterating over Ports

As Ports are also a GraphNode, they can be iterated just like the Nodes themselves.

// Iterate the ports of a Node
// Retrieve the NimbusRef for this material
const maxon::NimbusBaseRef nimbusRefMaterial = nodeMaterial->GetNimbusRef(currentNodeSpaceID);
if (nimbusRefMaterial == nullptr)
return maxon::NullptrError(MAXON_SOURCE_LOCATION);
// Retrieve the end node path
const maxon::NodePath materialEndNodePath = nimbusRefMaterial.GetPath(
if (!materialEndNodePath.IsPopulated())
return maxon::UnknownError(MAXON_SOURCE_LOCATION);
// Retrieve the end node of the node material
const maxon::GraphNode materialEndNode = nimbusRefMaterial.GetGraph().GetNode(materialEndNodePath);
if (!materialEndNode.IsValid())
return maxon::UnknownError(MAXON_SOURCE_LOCATION);
// Iterate all the port of the material end node
printPort = [&printPort, &materialEndNode](const maxon::GraphNode& port) -> maxon::Result<Bool>
{
String name = port.GetValue<decltype(maxon::NODE::BASE::NAME)>().GetValueOrNull() iferr_return;
if (name.IsEmpty())
{
name = port.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull() iferr_return;
}
ApplicationOutput("@ is a port of @ and have the name @", port, materialEndNode, name);
return port.GetChildren(printPort, maxon::NODE_KIND::NODE);
};
printPort(materialEndNode) iferr_return;
const char const char * name
Definition: abstract.h:195
Definition: c4d_string.h:39
const GraphModelRef & GetGraph() const
Definition: graph.h:1992
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
@ MATERIALENDNODE
Path of the material end node.
@ NODE
Indicates that the g-node is a true node.
#define iferr_scope
Definition: resultbase.h:1384

Retrieving an Ancestor

Retrieving an ancestor is useful to retrieve information related to a node.

// Retrieve the Ancestor of a port.
// Retrieve the port's name.
onePort.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull() iferr_return;
ApplicationOutput("the name of the port is @");
// Get the ancestor and print its information.
ApplicationOutput("@ is a port and a child of @", onePort, ancestor);
Result< typename SFINAEHelper< GraphNode, BASE >::type > GetAncestor(NODE_KIND mask) const
Definition: graph.h:1182

Retrieving Successors and Predecessors

To retrieve the successors or predecessors of a node, one can utilize the following functions: