maxon.GraphModelHelper

Description

Regroups functions to simplify the usage of the node API. Those functions help developers retrieving and manipulate information about a node system. Those functions mainly use internal function from the GraphModelInterface and do not offer more functionalities than what can be already done.

Inheritance diagram

Inheritance

Methods Signature

CreateInputPort(*args)

Creates and returns a new InputPort.

CreateOutputPort(*args)

Creates and returns a new OutputPort.

DeselectAll(*args)

Deselect all True Nodes and ports based on the NODE_KIND passed as parameter.

DeselectConnection(*args)

Deselects the connection between two ports. A connection hold a Wire object, itself holding 8 wires.

DeselectNode(*args)

Deselects a node or a port.

FindNodesByAssetId(graphModel, assetId, …)

Find all true nodes that have the same AssetId as the passed argument. Only nodes have assetId.

FindNodesById(graphModel, nodeId, kind, …)

Find all true nodes that have the same AssetId as the passed argument. Only nodes have assetId.

FindNodesByName(graphModel, nodeName, kind, …)

Find all GraphNode (true nodes or ports) that have the same name as the passed argument.

GetAllPredecessors(node, filter, callback)

Retrieves all nodes or ports connected to the passed port or node.

GetAllSuccessors(node, filter, callback)

Retrieves all nodes or ports connected to the passed port or node.

GetDirectPredecessors(node, filter, callback)

Retrieves the first level of nodes or ports connected to the passed port or node.

GetDirectSuccessors(node, filter, callback)

Retrieves the first level of nodes or ports connected to the passed port or node.

GetSelectedConnections(graphModel, callback)

Retrieves all the selected connections on the graph.

GetSelectedNodes(graphModel, kind, callback)

Retrieves all selected ports and/or true node on the graph depending on the NODE_KIND passed as argument.

IsConnected(*args)

Checks if this node or port is connected to another port.

IsConnectionSelected(*args)

Checks if a connection between two port is selected. A connection hold a Wire object.

IsNodeSelected(*args)

Returns if the node or the port is selected or not.

ListAllNodes(graphModel, matchingData, callback)

Retrieves all nodes having their stored data equals the ones in the passed DataDictionary.

MuteAllConnections(*args)

Mutes all incoming or outgoing connections of a node depending on the specified direction

MuteConnection(*args)

Mutes the connection between a node or port and another port.

RemoveAllConnections(*args)

Removes all the connection a true node have. The node should be a true node.

RemoveConnection(*args)

Removes the connections between two port.

SelectConnection(*args)

Selects the connection between two ports.

SelectNode(*args)

Selects a node or a port.

UnmuteAllConnections(*args)

Unmutes all the connections in one direction.

UnmuteConnection(*args)

Unmutes the connection between a node or port and another port.

Methods Definition

static GraphModelHelper.CreateInputPort(*args)
Creates and returns a new InputPort.
The port will be identify by the passed id and will be rename with the passed string.
This new port can only be created on the root or any group node.
Parameters
  • node (maxon.GraphNode) – The node where to create the input port.

  • id (Union[maxon.Id, str, maxon.String]) – The id of the port that need to be created.

  • name (Union[maxon.Id, str, maxon.String]) – The name of the port that need to be created.

Returns

The created port.

Return type

maxon.GraphNode

static GraphModelHelper.CreateOutputPort(*args)
Creates and returns a new OutputPort.
The port will be identify by the passed id and will be rename with the passed string.
This new port can only be created on the root or any group node.
Parameters
  • node (maxon.GraphNode) – The node where to create the output port.

  • id (Union[maxon.Id, str, maxon.String]) – The id of the port that need to be created.

  • name (Union[maxon.Id, str, maxon.String]) – The name of the port that need to be created.

Returns

The created port.

Return type

maxon.GraphNode

static GraphModelHelper.DeselectAll(*args)

Deselect all True Nodes and ports based on the NODE_KIND passed as parameter.

Parameters
static GraphModelHelper.DeselectConnection(*args)
Deselects the connection between two ports. A connection hold a Wire object, itself holding 8 wires.
There is at most one connection between two ports.
Parameters
static GraphModelHelper.DeselectNode(*args)

Deselects a node or a port.

Parameters

node (maxon.GraphNode) – The node or the port that have to be Deselected.

static GraphModelHelper.FindNodesByAssetId(graphModel, assetId, exactId, callback)
Find all true nodes that have the same AssetId as the passed argument. Only nodes have assetId.
This function will return several nodes if they share the same assetId.
Parameters
  • graphModel (maxon.GraphModelRef) – The GraphModelRef to search for the nodes.

  • assetId (Union[str, maxon.String, maxon.Id]) – The AssetId of the true node or the port to look for. This has the form of a reversed domain string. e.g “net.maxon.asset.utility.color”

  • exactId (bool) – Set True if the exact id should be search. If this is set to False, check if the passed id is contained in the node assetID.

  • callback (Callable[[maxon.GraphNode], bool]) – This callback will receive all ports and/or True Node that have the same name.

static GraphModelHelper.FindNodesById(graphModel, nodeId, kind, direction, exactId, callback)
Find all true nodes that have the same AssetId as the passed argument. Only nodes have assetId.
This function will return several nodes if they share the same assetId.
Parameters
  • graphModel (maxon.GraphModelRef) – The GraphModelRef to search for the nodes.

  • nodeId (Union[str, maxon.String, maxon.Id]) – The id of the true node or the port to look for.

  • kind (maxon.NODE_KIND) – Filter that will be applied to the kind of GraphNode we are looking for. By default, All type (true node/ports)

  • direction (maxon.PORT_DIR) – Filter the GraphNode by direction. Input or Output.

  • exactId (bool) – Set true if the exact id should be search. If this is set to false, check if the passed id is contained in the GraphNode’s id.

  • callback (Callable[[maxon.GraphNode], bool]) – This callback will receive all ports and/or True Node that have the same name.

static GraphModelHelper.FindNodesByName(graphModel, nodeName, kind, direction, exactName, callback)
Find all GraphNode (true nodes or ports) that have the same name as the passed argument.
This function will return several nodes/port if they share the same name.

Warning

Name of true nodes or port can change depending on the language of Cinema4D.
Search based on name should be avoided as mush as possible, unless you are sure the name will not be different on any setup.
Parameters
  • graphModel (maxon.GraphModelRef) – The GraphModelRef to search for the nodes.

  • nodeName (Union[str, maxon.String]) – The name of the true node or the port to look for.

  • kind (maxon.NODE_KIND) – Filter that will be applied to the kind of GraphNode we are looking for. By default, All type (true node/ports)

  • direction (maxon.PORT_DIR) – Filter the GraphNode by direction. Input or Output.

  • exactName (bool) – Set true if the exact name should be search. If this is set to false, check if the passed name is contained in the GraphNode’s name.

  • callback (Callable[[maxon.GraphNode], bool]) – This callback will receive all ports and/or true node that have the same name.

static GraphModelHelper.GetAllPredecessors(node, filter, callback)

Retrieves all nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the inputs.

Parameters
  • node (maxon.GraphNode) – The starting point to retrieve all the predecessor. A node or a port can be used. If a port is used, an input port must be used.

  • filter (maxon.NODE_KIND) – The NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.

  • callback (Optional[List[], Callable[[maxon.GraphNode], bool]]) –

    If a callable, this will be called with all the connected nodes.
    If a list is passed, connected nodes will be added to it.
    If a None is passed, a list containing connected nodes will be returned.

static GraphModelHelper.GetAllSuccessors(node, filter, callback)

Retrieves all nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the outputs.

Parameters
  • node (maxon.GraphNode) – The starting point to retrieve all the successors. A node or a port can be used. If a port is used, an output port must be used.

  • filter (maxon.NODE_KIND) – The NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.

  • callback (Optional[List[], Callable[[maxon.GraphNode], bool]]) –

    If a callable, this will be called with all the connected nodes.
    If a list is passed, connected nodes will be added to it.
    If a None is passed, a list containing connected nodes will be returned.

static GraphModelHelper.GetDirectPredecessors(node, filter, callback)

Retrieves the first level of nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the inputs.

Parameters
  • node (maxon.GraphNode) – The starting point to retrieve the direct predecessors. A node or a port can be used. If a port is used, an input port must be used.

  • filter (maxon.NODE_KIND) – The NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.

  • callback (Optional[List[], Callable[[maxon.GraphNode], bool]]) –

    If a callable, this will be called with all the connected nodes.
    If a list is passed, connected nodes will be added to it.
    If a None is passed, a list containing connected nodes will be returned.

static GraphModelHelper.GetDirectSuccessors(node, filter, callback)

Retrieves the first level of nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the outputs.

Parameters
  • node (maxon.GraphNode) – The starting point to retrieve the direct successors. A node or a port can be used. If a port is used, an output port must be used.

  • filter (maxon.NODE_KIND) – The NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.

  • callback (Optional[List[], Callable[[maxon.GraphNode], bool]]) –

    If a callable, this will be called with all the connected nodes.
    If a list is passed, connected nodes will be added to it.
    If a None is passed, a list containing connected nodes will be returned.

static GraphModelHelper.GetSelectedConnections(graphModel, callback)

Retrieves all the selected connections on the graph. A connection hold a Wire object. There is none or only one connection between two ports, and this connection is composed by multiple wires.

Parameters
static GraphModelHelper.GetSelectedNodes(graphModel, kind, callback)

Retrieves all selected ports and/or true node on the graph depending on the NODE_KIND passed as argument.

Parameters
  • graphModel (maxon.GraphModelRef) – The GraphModelRef to retrieve the selected elements.

  • callback (Callable[[maxon.GraphNode], bool]) – This callback will receive all selected ports and/or True Node.

  • kind (maxon.NODE_KIND) – The GraphNode kind to check.

static GraphModelHelper.IsConnected(*args)
Checks if this node or port is connected to another port.
If a true node is passed, every port on the node will be tested. If a port is passed, only the passed port will be tested.
Parameters
Returns

True if ports are connected, otherwise False.

Return type

bool

static GraphModelHelper.IsConnectionSelected(*args)
Checks if a connection between two port is selected. A connection hold a Wire object.
There is at most one connection between two port, but this connection is composed by 8 wires.
If a GraphNode is passed instead a NodePath, the GraphNode will be converted to NodePath.
Parameters
Returns

True if the connection is selected, otherwise False.

Return type

bool

static GraphModelHelper.IsNodeSelected(*args)

Returns if the node or the port is selected or not.

Parameters

node (maxon.GraphNode) – The Node or the Port to check.

Returns

True if the node or the port is selected, otherwise False.

Return type

bool

static GraphModelHelper.ListAllNodes(graphModel, matchingData, callback)
Retrieves all nodes having their stored data equals the ones in the passed DataDictionary.
The passed DataDictionary can have one or multiple data defined.
The function will compare all the value inside the DataDictionary, if they all match, the node will be returned.
# Retrieve all nodes with a defined name
nodeProperties = maxon.DataDictionary();
nodeProperties.Set(maxon.NODE.BASE.NAME, groupName)

for child in maxon.GraphModelHelper.ListAllNodes(nodeGraph, nodeProperties):
    print(f"node that have this name {child}")
Parameters
  • graphModel (maxon.GraphModelRef) – The GraphModelRef to list the node.

  • matchingData (maxon.DataDictionary) –

    The Dictionary filled with the data we want to compare the GraphNode with.
    All node founded that have the same data values than those passed within the Dictionary.

  • callback (Callable[[maxon.GraphNode], bool]) – This callback will receive all nodes founded that have the same data values than those passed within the Dictionary

static GraphModelHelper.MuteAllConnections(*args)
Mutes all incoming or outgoing connections of a node depending on the specified direction
Parameters
  • node (maxon.GraphNode) – The true node to mute all the connections.

  • direction (maxon.PORT_DIR) – The direction where all connection will be muted.

static GraphModelHelper.MuteConnection(*args)
Mutes the connection between a node or port and another port.
If a true node is passed, and the port is connected to one or several input port, all the connections will be muted between the port and the node.
For example, a constant port is connected to several input port of another node.
Parameters
static GraphModelHelper.RemoveAllConnections(*args)
Removes all the connection a true node have. The node should be a true node.
To remove connection for a port, use GraphNodeFunctions.RemoveConnections()
Parameters

node (maxon.GraphNode) – The node to remove all the connections to.

static GraphModelHelper.RemoveConnection(*args)

Removes the connections between two port.

Parameters
static GraphModelHelper.SelectConnection(*args)

Selects the connection between two ports.

Parameters
static GraphModelHelper.SelectNode(*args)

Selects a node or a port.

Parameters

node (maxon.GraphNode) – The node or the port that have to be selected.

static GraphModelHelper.UnmuteAllConnections(*args)

Unmutes all the connections in one direction.

Parameters
  • node (maxon.GraphNode) – The node to unmute the connection.

  • direction (maxon.PORT_DIR) – The direction where all connection will be Unmuted

static GraphModelHelper.UnmuteConnection(*args)
Unmutes the connection between a node or port and another port.
If a true node is passed, depending of the port passed direction, every output or every input will be unmuted.
Parameters
  • srcNode (maxon.GraphNode) – The node to unmute the connection with.

  • dstPort (maxon.GraphNode) – The other port that the connection must be Unmuted.