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:
- maxon::GraphNode::GetInnerNodes: Yields all inner nodes of this node matching a filtering mask. The recursive traversal will stop at nodes which do not match the filtering mask.
- maxon::GraphNode::GetChildren: Gets all children of this node. For a true node this will be its child nodes as well as a single input port list and a single output port list. Otherwise, the children are ports.
- maxon::nodes::Node::GetChildren: Returns an iterator for the child nodes of this node. This does include true nodes, but not the input and output port lists.
- Note
- GetChildren function from GraphNode allow you to use maxon::ValueReceiver which is a template for a generic delegate function. It can be a lambda function or a BaseArray for example.
FindNode = [&FindNode, &searchingFor, &searchNode]
{
{
searchNode = child;
return true;
}
};
Definition: delegate.h:240
Result< Bool > GetChildren(const ValueReceiver< const GraphNode & > &callback, NODE_KIND mask=NODE_KIND::ALL_MASK) const
Definition: graph.h:1160
Bool IsValid() const
Definition: graph.h:1963
Definition: apibaseid.h:253
COMPARERESULT Compare(const LiteralId &other) const
Definition: apibaseid.h:116
Definition: resultbase.h:766
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#define iferr_return
Definition: resultbase.h:1519
Finding a Specific True Node
For nodes can be searched with their identifier, name or other types of data.
maxon::DataDictionary
dict;
{
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.
const maxon::NimbusBaseRef nimbusRefMaterial = nodeMaterial->GetNimbusRef(currentNodeSpaceID);
if (nimbusRefMaterial == nullptr)
const maxon::NodePath materialEndNodePath = nimbusRefMaterial.GetPath(
if (!materialEndNodePath.IsPopulated())
{
{
name = port.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull()
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.
onePort.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull()
iferr_return;
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: