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

maxon.GraphDescription.Description

Returns the key for a description field in a description.

maxon.GraphDescription.Flags

Returns the key for a flags field in a description.

maxon.GraphDescription.Id

Returns the key for a node ID field in a description.

maxon.GraphDescription.Language

Returns the key for a language ID field in a description.

maxon.GraphDescription.Query

Returns the key for a query field in a description.

maxon.GraphDescription.QueryMode

Returns the key for a query mode field in a description.

maxon.GraphDescription.Space

Returns the key for a node space ID field in a description.

maxon.GraphDescription.Type

Returns the key for a node type field in a description.

Methods Signature

ApplyDescription(graph, description[, …])

Applies the given graph description to the given nodes graph.

CreateGraph([element, nodeSpaceId, …])

Returns the nodes graph for the given scene #element and #nodeSpaceId.

Methods Definition

static GraphDescription.ApplyDescription(graph: maxon.frameworks.nodes.NodesGraphModelRef, description: dict, nodeSpace: str = '', language: str = '', callback: callable = None) → 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.

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.

The element can be a c4d.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.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

maxon.NodesGraphModelRef