Nodes Manual

About

maxon::nodes::Node is a node based on maxon::nodes::GNode and maxon::nodes::NodeFunctions. It is stored in a node system.

Note
It is preferred to use the more generic graph nodes, see GraphModelInterface Manual and GraphNodes Manual.

Access

Nodes are obtained from a nodes graph model; see NodesGraphModelInterface Manual and NodeMaterial Manual.

A given maxon::GraphNode can be converted with:

See GraphNodes Manual.

// This example accesses the root node of the given node material for the active node space.
// get active node space ID.
const maxon::Id nodeSpaceID = GetActiveNodeSpaceId();
// check material
if (nodeMaterial->HasSpace(nodeSpaceID) == false)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
// get graph model, node system and root node
const maxon::nodes::NodesGraphModelRef& graph = nodeMaterial->GetGraph(nodeSpaceID) iferr_return;
const maxon::nodes::NodeSystem& system = graph.GetNodeSystem();
maxon::nodes::Node node = system.GetRoot();
maxon::Id GetActiveNodeSpaceId()
Definition: apibaseid.h:253
Definition: nodesystem.h:2218
Definition: nodesystem.h:835
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define iferr_return
Definition: resultbase.h:1519
Definition: node.h:10

Use

maxon::nodes::Node is based on maxon::nodes::NodeFunctions. Inherited functions allow to access parents and children:

// This example prints the IDs of all children of the given node.
// check children
for (auto nodeSelector : node.GetChildren())
{
maxon::nodes::Node child = nodeSelector iferr_return;
DiagnosticOutput("Child ID: @", child.GetId());
}
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
// This example searches for a child node with the given ID.
const maxon::Id materialID { "material" };
const maxon::nodes::Node materialNode = rootNode.FindChild(materialID) iferr_return;
Result< NodeSelector< BASE::MUTABLE > > FindChild(const InternedId &name) const
Definition: nodesystem.h:2070

A node contains lists of ports:

See Port Lists below.

// This example obtains both the input and output port lists of the given node.
const maxon::nodes::PortList inputs = node.GetInputs() iferr_return;
const maxon::nodes::PortList outputs = node.GetOutputs() iferr_return;
Definition: nodesystem.h:2777

Further functions are:

maxon::nodes::Node is based on maxon::nodes::GNodeBase. Basic functions allow to check if a node is a valid reference:

A GNode is part of a node system:

Further node properties are:

A node can be compared with:

maxon::nodes::GNode is the base class of immutable node references. It is based on maxon::nodes::GNodeFunctions. This class allows to access node attributes:

// This example read the node name and node space context from the found node.
// find the node with the given ID
const maxon::Id materialID { "material" };
const maxon::nodes::Node materialNode = rootNode.FindChild(materialID) iferr_return;
// get the node name
const maxon::String nodeName = materialNode.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull() iferr_return;
// get the space ID.
const maxon::DataDictionary& currentPreviewContext = materialNode.GetValue<decltype(maxon::nodes::NODESPACE::NodeSpaceContext)>().GetValueOrNull() iferr_return;
const maxon::Id currentSpaceId = currentPreviewContext.Get(maxon::nodes::NODESPACE::SPACEID, maxon::Id());
DiagnosticOutput("Node Name: @", nodeName);
DiagnosticOutput("Node Space: @", currentSpaceId);
const Id & Get() const
Definition: apibaseid.h:185
Definition: string.h:1235
// This example gets all attributes from the given node for the defined mask.
const maxon::GraphAttribute::FLAGS mask = maxon::GraphAttribute::FLAGS::TYPE_MASK;
materialNode.GetValues(mask, map, true, false) iferr_return;
for (const auto& attr : map)
{
// get id and data
const maxon::InternedId id = attr.GetFirst();
const maxon::ConstDataPtr data = attr.GetSecond();
// get time stamp
const maxon::TimeStamp timeStamp = materialNode.GetAttributeStamp(id);
DiagnosticOutput("@ : @ (at @)", id, data, timeStamp);
}
Definition: datatypebase.h:1800
Definition: hashmap.h:1119
Definition: datatypelib.h:31
TYPE_MASK
Use this mask to test for the type (one of DIRECT, DERIVED, USER_STATE or DERIVED|USER_STATE).
Definition: graphattribs.h:39
UInt64 TimeStamp
Definition: graph.h:17

Further functions are:

// This example read the node name and node space context from the found node.
// find the node with the given ID
const maxon::Id materialID { "material" };
const maxon::nodes::Node materialNode = rootNode.FindChild(materialID) iferr_return;
// get the node name
const maxon::String nodeName = materialNode.GetValue<decltype(maxon::EffectiveName)>().GetValueOrNull() iferr_return;
// get the space ID.
const maxon::DataDictionary& currentPreviewContext = materialNode.GetValue<decltype(maxon::nodes::NODESPACE::NodeSpaceContext)>().GetValueOrNull() iferr_return;
const maxon::Id currentSpaceId = currentPreviewContext.Get(maxon::nodes::NODESPACE::SPACEID, maxon::Id());
DiagnosticOutput("Node Name: @", nodeName);
DiagnosticOutput("Node Space: @", currentSpaceId);

A maxon::nodes::MutableRoot is returned from maxon::nodes::NodeSystemClassInterface::CreateNodeSystem() and is the root node of node systems with write access.

maxon::nodes::MutableNode represents a node within a NodeSystem with write access.

  • maxon::nodes::ToImmutable(): Casts this MutableNode to an immutable Node.
  • maxon::nodes::Ungroup(): Dissolves this node into its children.
  • maxon::nodes::MoveToNodeSystem()

Port Lists

A maxon::nodes::PortList represents a port list within a node system. Each Node has exactly two port lists, one for its top-level input ports and one for its top-level output ports.

A given maxon::GraphNode can be converted to a port list with:

A maxon::nodes::PortList is based on maxon::nodes::PortListFunctions:

Ports

A maxon::nodes::Port represents a port within a node system.

A given maxon::GraphNode can be converted to a port with:

A maxon::nodes::Port is based on maxon::nodes::PortFunctions:

// This example searches a child node of the given root node
// and a specific port in the node's input port list.
// find the "material" node
const maxon::Id materialID { "material" };
const maxon::nodes::Node materialNode = rootNode.FindChild(materialID) iferr_return;
// get input ports
const maxon::nodes::PortList inputs = materialNode.GetInputs() iferr_return;
// find the "normal" port
const maxon::Id normalID { "normal" };
const maxon::nodes::Port normalPort = inputs.FindPort(normalID) iferr_return;
Result< PortListSelector< BASE::MUTABLE > > GetInputs() const
Definition: nodesystem.h:2141
Definition: nodesystem.h:3066
Result< PortSelector< BASE::MUTABLE > > FindPort(const InternedId &port) const
Definition: nodesystem.h:2737
// This example reads various properties of the given port.
DiagnosticOutput("Port: @", port.GetId());
// prints the port name
const maxon::String* const directlySetName = port.GetValue<decltype(maxon::NODE::BASE::NAME)>() iferr_return;
if (directlySetName != nullptr)
DiagnosticOutput("Name: @", directlySetName);
// print the data type
const maxon::DataType& dataType = port.GetValue<decltype(maxon::nodes::PortType)>().GetValueOrNull() iferr_return;
DiagnosticOutput("DataType: @", dataType);
// print the default value
const maxon::Data* const def = port.GetValue<decltype(maxon::DESCRIPTION::DATA::BASE::DEFAULTVALUE)>() iferr_return;
if (def != nullptr)
DiagnosticOutput("Default Value: @", def);
// check if this is a hidden port
maxon::nodes::PORT_FLAGS flags = port.GetValue<decltype(maxon::nodes::PortFlags)>().GetValueOrNull() iferr_return;
{
DiagnosticOutput("Port is hidden.");
}
PyCompilerFlags * flags
Definition: ast.h:14
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:65
Definition: datatypebase.h:1199
Definition: datatypebase.h:772
PORT_FLAGS
Type of the PortFlags attribute.
Definition: portattributes.h:380
@ HIDDEN
The port shall be hidden.
PyObject struct PyModuleDef * def
Definition: pycore_pystate.h:130

maxon::nodes::MutablePort is based on maxon::nodes::MutablePortFunctions:

Connections

maxon::nodes::Connection is a tuple of maxon::node::Port and maxon::Wires.

// This example gets the connections of the input ports of the given node.
// get input ports
maxon::nodes::PortList inPorts = node.GetInputs() iferr_return;
// loop over input ports
for (auto it : inPorts.GetPorts())
{
// get connections
// check if this port has one input connection
if (unique.GetCount() == 1)
{
// get connection
const maxon::nodes::Connection connection = *unique.Get();
// the other port this port is connected to
const maxon::nodes::Port connectedPort = connection.GetFirst();
// the other node this port is connected to
const maxon::nodes::Node sourceNode = connectedPort.GetNode() iferr_return;
// print source node and port
const maxon::Id sourceNodeId = sourceNode.GetId();
const maxon::Id sourcePortId = connectedPort.GetId();
DiagnosticOutput("Connected to \"@\" : \"@\"", sourceNodeId, sourcePortId);
}
}
Definition: tuple.h:611
Definition: valuereceiver.h:126
Int GetCount() const
Definition: valuereceiver.h:163
const Opt< typename std::decay< T >::type > & Get() const
Definition: valuereceiver.h:148
Result< Bool > GetConnections(PORT_DIR dir, const ValueReceiver< const ConnectionSelector< BASE::MUTABLE > & > &conns, Wires mask=Wires::All(), NodeSystemInterface::GET_CONNECTIONS_MODE mode=NodeSystemInterface::GET_CONNECTIONS_MODE::CONNECTIONS) const
Definition: nodesystem.h:2894
Result< Iterator > GetPorts() const
Definition: nodesystem.h:2713
@ INPUT
Input direction, i.e., an input port or an incoming connection.