Collection

The Collection object defines a collection of data. Collection properties can be added NodeTree and Task.

Data type

Collection can have different data type:

Task

PropertyCollection, InputSocketCollection and OutputSocketCollection belong to a Task

For the output sockets, the length and order are important. It should be the same as the order of the results of the task executor.

from node_graph.collection import (
    PropertyCollection,
    InputSocketCollection,
    OutputSocketCollection,)
self.properties = PropertyCollection(self)
self.inputs = InputSocketCollection(self)
self.outputs = OutputSocketCollection(self)

Use

One can get a item by its name or index:

# by name
ng.tasks["Add task"].update_state()
float1.properties["Float"].value = 2.0
# by index
ng.tasks[1].update_state()
float1.properties[0].value = 2.0
ng.add_link(float1.outputs[0], add1.inputs[0])

List of all Methods

class node_graph.collection.Collection(parent: object | None = None, graph: object | None = None, pool: object | None = None, entry_point: str | None = None, post_creation_hooks: List[Callable] | None = None, post_deletion_hooks: List[Callable] | None = None)[source]

Collection of instances of a property. Like an extended list, with the functions: new, find, delete, clear.

class node_graph.collection.DependencyCollection(*items: Task | BaseSocket)[source]

A collection that can be used to create dependencies between multiple nodes/sockets.

This does not inherit from Collection, as it is a simple wrapper around items strictly for creating/chaining dependencies.

class node_graph.collection.LinkCollection(graph: object)[source]

Link colleciton

clear() None[source]

Remove all links from this collection. And remove the link in the nodes.

class node_graph.collection.PropertyCollection(parent: object | None = None, pool: object | None = None, entry_point: str | None = 'node_graph.property')[source]

Property colleciton

class node_graph.collection.TaskCollection(graph: object | None = None, pool: object | None = None, entry_point: str | None = 'node_graph.task', post_creation_hooks: List[Callable] | None = None)[source]

Task collection

node_graph.collection.decorator_check_identifier_name(func: Callable) Callable[source]

Check identifier and name exist or not.

Parameters:

func (_type_) – _description_

node_graph.collection.get_entries(entry_point_name: str) Dict[str, EntryPoint][source]

Get entries from the entry point.

node_graph.collection.get_item_class(identifier: EntryPoint | Task, pool: Dict[str, EntryPoint]) Task[source]

Get the item class from the identifier.

node_graph.collection.group(*items)[source]

Create a dependency collection of items (nodes/sockets).