maxon.GraphDescription¶
Description¶
Provides functions and constants to read and write node graphs from and into the graph description format.
A graph description is JSON-like format to describe complete or partial node graphs for arbitrary node spaces. Graph descriptions can describe node types and their attributes over their labels in a natural language, absolute and lazy node paths, and queries to select entities in a graph by their values.
Inheritance diagram¶
Attributes¶
Returns the key for a command field in a description. |
|
Returns the key for a default node command field in a description. |
|
Returns the key for a description field in a description. |
|
Returns the key for an isolate node command field in a description. |
|
Returns the key for a flags field in a description. |
|
Returns the key for a group command field in a description. |
|
Returns the key for a hide ports command field in a description. |
|
Returns the key for a node ID field in a description. |
|
Returns the key for a language ID field in a description. |
|
Returns the key for a query field in a description. |
|
Returns the key for a query mode field in a description. |
|
Returns the key for a remove node command field in a description. |
|
Returns the key for a change ports count command field in a description. |
|
Returns the key for a show ports command field in a description. |
|
Returns the key for a node space ID field in a description. |
|
Returns the key for a node type field in a description. |
|
Returns the key for an ungroup command field in a description. |
Methods Signature¶
|
Applies the given graph description to the given nodes graph. |
|
Returns the nodes graph for the given scene #element and #nodeSpaceId. |
|
Returns the nodes graph for the given scene element and nodeSpaceId. |
|
Returns all material graphs in the given scene #doc which are in the given #nodeSpaceId.
|
Methods Definition¶
-
static
GraphDescription.
ApplyDescription
(graph: maxon.frameworks.nodes.NodesGraphModelRef, description: dict, nodeSpace: str = '', language: str = '', callback: callable = None, validateAbsolutePaths: bool = True) → dict¶ Applies the given graph description to the given nodes graph.
- Parameters
graph (
maxon.NodesGraphModelRef
) – The nodes graph to apply the description to.description (Union[dict, list[dict]]) – The description to apply to graph.
nodeSpace (Union[str,
maxon.String
,maxon.Id
,maxon.InternedId
]) – The node space the given description is intended for. When the empty string or Id are passed, the space will be deduced from the passed graph. Apart from raising errors a bit earlier, this argument has only the function to make for more declarative code which clearly states for which node space a description is intended. Defaults to the empty string.nodeSpace – The natural language the given description is referencing. When the empty string or Id are passed, the currently active language of Cinema 4D is used to parse the description. Only relevant when using label references. Defaults to the empty string.
callback (Union[callable, None]) – Will be called for each scope in the given description before it is parsed into the given graph. Defaults to None.
validateAbsolutePaths – When True, absolute node paths in the given description will still be validated with the underlying graph description cache. When False, absolute node paths will invoked without checking the cache. This has the advantage that one can address ports and attributes that are not cacheable. The disadvantage is that one will get less precise error messages when a cacheable path is wrong. Should only be set to False for descriptions which raise the error ‘WARNING: Failed to cache child attributes for type ‘@’ in port bundle ‘@’. Referencing its children is only possible via absolute node paths.’. And then only when one actually wants to reference one of these children. This currently happens for example in the standard renderer node space for some color ports which decompose themselves into (r, g, b) child ports. Setting the color as a whole will work, but setting one of the child ports will not unless one uses an absolute node path and sets this flag to False, so that the path is being used without being validated. Defaults to True.
- Returns
All nodes in the given graph as (ID, node) key-value pairs.
- Return type
dict
-
static
GraphDescription.
CreateGraph
(element: c4d.BaseList2D = None, nodeSpaceId: str = '', createEmpty: bool = True, name: str = '') → maxon.frameworks.nodes.NodesGraphModelRef¶ Returns the nodes graph for the given scene #element and #nodeSpaceId.
Deprecated since version 2025.0: Use
GetGraph()
instead.
-
static
GraphDescription.
GetGraph
(element: c4d.BaseList2D = None, nodeSpaceId: str = '', createEmpty: bool = True, name: str = '') → maxon.frameworks.nodes.NodesGraphModelRef¶ Returns the nodes graph for the given scene element and nodeSpaceId.
The element can be a c4d.documents.BaseDocument (for the document wide scene nodes graph), a c4d.BaseObject (for capsules), or a material (for material graphs), or None (to create a material in the active document). When the passed element does not yet have a graph in the requested node space, it will be created.
- Parameters
element (Union[
c4d.documents.BaseDocument
,c4d.BaseObject
,c4d.BaseMaterial
, None]) – The scene element to get the graph for. Can be None to create a material in the active document. Defaults to None.nodeSpaceId (Union[str,
maxon.String
,maxon.Id
,maxon.InternedId
]) – The node space to retrieve the graph for. When the empty ID is passed, it will default to the active node space for materials and the neutron node space for everything else. Defaults to the empty string.createEmpty (bool) – When True, new graphs will be created as an empty graph, when False the default graph will be created. Defaults to True.
name (str) – The name to give the material which is created when #element is the None. Will be ignored when the empty string. Defaults to the empty string.
- Returns
The retrieved graph.
- Return type
-
GraphDescription.
GetMaterialGraphs
(nodeSpaceId: str) → BaseArray[NodesGraphModelRef]¶ - Returns all material graphs in the given scene #doc which are in the given #nodeSpaceId.
- Parameters
doc (
c4d.documents.BaseDocument
) – The document to get the material graphs from.nodeSpaceId (str) – The node space to retrieve the graphs for. Cannot be the empty ID.
- Returns
All material graphs in the given scene #doc which are of the given #nodeSpaceId.
- Return type