c4d.NodeMaterial

class c4d.NodeMaterial
The node-based material with the Mbase type.
This class is a collection of accessors to node-related functionality that are grouped for clarity purposes.
Note that any c4d.BaseMaterial can be elevated to a c4d.NodeMaterial, no special construction is needed.

New in version S24.

Methods Signatures

NodeMaterial.HasSpace(self, spaceId)

Checks whether the node space under the provided id was instantiated for the material.

NodeMaterial.GetMaterialNodePath(self, spaceId)

Returns the node path to the material end node.

NodeMaterial.GetSoloNodePath(self, spaceId)

Returns the node path to the solo node.

NodeMaterial.GetBaseListForNode(self, spaceId, nodePath)

Returns the corresponding c4d.BaseList2D element for a maxon.GraphNode.

NodeMaterial.GetDescIDForNodePort(self, spaceId, node, port)

Calculates the c4d.DescID for a given port.

NodeMaterial.GetGraph(self, spaceId)

Returns the node graph for the provided node space id.

NodeMaterial.AddGraph(self, spaceId)

Creates a node graph for the provided node space identifier if a graph does not already exist.

NodeMaterial.CreateDefaultGraph(self, spaceId)

Creates a node graph populated with default nodes for the provided node space identifier if a graph does not already exist.

NodeMaterial.CreateEmptyGraph(self, spaceId)

Creates an empty node graph for the provided node space identifier if a graph does not already exist.

NodeMaterial.RemoveGraph(self, spaceId)

Removes a node graph for the provided node space id if there is a graph.

NodeMaterial.UuidToBaseList2D(self, spaceId, uuid)

Returns the c4d.BaseList2D element with the given uuid.

NodeMaterial.BaseList2DToUuid(self, spaceId, object)

Returns the uuid of the given c4d.BaseList2D object.

Static Methods Signatures

c4d.NodeMaterial.GetTextureSearchPaths(secondaryPath, documentPath)

Determines the paths pointing to directories that are used to reference images by relative path in a particular c4d.documents.BaseDocument.

c4d.NodeMaterial.GetMaterial(graph)

Returns the material owner of the provided graph.

Inheritance

Parent Class:

Methods Documentation

NodeMaterial.HasSpace(self, spaceId)

Checks whether the node space under the provided id was instantiated for the material.

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

Returns True if the node space exists, False otherwise.

Return type

bool

NodeMaterial.GetMaterialNodePath(self, spaceId)

Returns the node path to the material end node.

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

The path to the material end node.

Return type

maxon.NodePath

NodeMaterial.GetSoloNodePath(self, spaceId)

Returns the node path to the solo node.

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

The path to the solo node, empty if nothing was soloed.

Return type

maxon.NodePath

NodeMaterial.GetBaseListForNode(self, spaceId, nodePath)

Returns the corresponding c4d.BaseList2D element for a maxon.GraphNode.

Parameters
Returns

BaseList2D element. The return value can be None if there’s no corresponding element, or if it refers to an inner node.

Return type

Optional[c4d.BaseList2D]

NodeMaterial.GetDescIDForNodePort(self, spaceId, node, port)

Calculates the c4d.DescID for a given port.

Parameters
  • spaceId (maxon.Id) – The id of the node space.

  • node (maxon.node) – The node that owns the port.

  • port (maxon.node) – The port.

Returns

The description ID of the port.

Return type

c4d.DescID

NodeMaterial.GetGraph(self, spaceId)

Returns the node graph for the provided node space id.

Parameters

spaceId (maxon.Id) – The id of the node space.

Raises

SystemError – If the material does not have this space.

Returns

Returns the node graph.

Return type

maxon.NodesGraphModelRef

NodeMaterial.AddGraph(self, spaceId)

Creates a node graph for the provided node space identifier if a graph does not already exist.

Deprecated since version 2023.1.0: Use NodeMaterial.CreateDefaultGraph() or NodeMaterial.CreateEmptyGraph().

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

The added graph.

Return type

maxon.NodesGraphModelRef

NodeMaterial.CreateDefaultGraph(self, spaceId)

Creates a node graph populated with default nodes for the provided node space identifier if a graph does not already exist.

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

The added graph.

Return type

maxon.NodesGraphModelRef

NodeMaterial.CreateEmptyGraph(self, spaceId)

Creates an empty node graph for the provided node space identifier if a graph does not already exist.

Parameters

spaceId (maxon.Id) – The id of the node space.

Returns

The added graph.

Return type

maxon.NodesGraphModelRef

NodeMaterial.RemoveGraph(self, spaceId)

Removes a node graph for the provided node space id if there is a graph.

Parameters

spaceId (maxon.Id) – The id of the node space.

NodeMaterial.UuidToBaseList2D(self, spaceId, uuid)

Returns the c4d.BaseList2D element with the given uuid.

Parameters
Returns

BaseList2D object.

Return type

c4d.BaseList2D

NodeMaterial.BaseList2DToUuid(self, spaceId, object)

Returns the uuid of the given c4d.BaseList2D object.

Parameters
Return type

maxon.Uuid

Returns

The uuid

Static Methods Documentation

static c4d.NodeMaterial.GetTextureSearchPaths(secondaryPath, documentPath)

Determines the paths pointing to directories that are used to reference images by relative path in a particular c4d.documents.BaseDocument.

>>> doc = c4d.documents.GetActiveDocument()
>>> secondaryPath = maxon.Url(doc.GetDataInstance()[c4d.DOCUMENT_SECONDARYPATH])
>>> docPath = maxon.Url(doc.GetDocumentPath())
>>> docPath
file:///C:/Users/m_adam/Documents

>>> textureSearchPaths = c4d.NodeMaterial.GetTextureSearchPaths(secondaryPath, docPath)
>>> for path in textureSearchPaths:
...     print(path)

file:///C:/Users/m_adam/Documents
file:///C:/Users/m_adam/Documents/tex
file:///C:/Users/m_adam/Documents/MAXON/Build/24.029
file:///C:/Users/m_adam/Documents/MAXON/Build/24.029_/tex
file:///C:/Users/m_adam/AppData/Roaming/Maxon/24.029_0F21F86A
file:///C:/Users/m_adam/AppData/Roaming/Maxon/24.029_0F21F86A/tex
Parameters
  • secondaryPath (maxon.Url) – Allows to provide the DOCUMENT_SECONDARYPATH

  • documentPath (maxon.Url) – The path of the BaseDocument.

Return type

maxon.BaseArray (maxon.Url)

Returns

The set of paths in which the images may be located.

static c4d.NodeMaterial.GetMaterial(graph)

Returns the material owner of the provided graph.

Note

The returned BaseMaterial is only safe for access in the usual places of the API.
You must avoid to perform read or write access to it in an arbitrary worker thread.
Parameters

graph (maxon.NodesGraphModelRef) – The node graph of the owner.

Returns

Returns the owner of the node graph, None if unknown or on failure to retrieve.

Return type

Optional[c4d.BaseMaterial]