Collection

class Collection(bcoll)

Data class Collection

classmethod Input(name='Collection', description='')

Create a Collection input socket in the Group Input Node

Parameters
  • name – The socket name

  • description – User tip

Returns

The Collection data socket

Return type

Collection

property bl_idname

Shortcut for self.bsocket.bl_idname

property bnode

Shortcut for self.bsocket.node

bsocket

The wrapped geometry node socket

connected_sockets()

Returns the list of Socket instances linked to this socket.

data_socket

Used by domain

static domain_data_type(value)

Returns the domain to which the socket belongs

Parameters

value (bpy.types.NodeSocket, Socket) – The socket

Returns

Domain code in [‘BOOLEAN’, ‘INT’, ‘FLOAT’, ‘FLOAT_VECTOR’, ‘FLOAT_COLOR’]

Return type

str

Correspondance table

Socket bl_idname

Domain code

NodeSocketBool

‘BOOLEAN’

NodeSocketInt

‘INT’

NodeSocketIntUnsigned

‘INT’

NodeSocketFloat

‘FLOAT’

NodeSocketFloatFactor

‘FLOAT’

NodeSocketFloatAngle

‘FLOAT’

NodeSocketFloatDistance

‘FLOAT’

NodeSocketVector

‘FLOAT_VECTOR’

NodeSocketVectorEuler

‘FLOAT_VECTOR’

NodeSocketVectorXYZ

‘FLOAT_VECTOR’

NodeSocketVectorTranslation

‘FLOAT_VECTOR’

NodeSocketColor

‘FLOAT_COLOR’

NodeSocketString

‘FLOAT_COLOR’

field_of

Used by field to implement transfer attribute mechanism. This property is set to all node output sockets.

static get_bl_idname(class_name)

Get the node socket bl_idname name from the Socket class

Parameters

class_name (str) – The class name

Returns

The bl_idname associated to this class name

Return type

str

Used to create a new group input socket. Called in DataClass.Input method to determine which socket type must be created.

Note that here the class_name argument accepts additional values which correspond to sub classes:

Unsigned

Integer sub class (NodeSocketIntUnsigned)

Factor

Float sub class (NodeSocketFloatFactor)

Angle

Float sub class (NodeSocketFloatAngle)

Distance

Float sub class (NodeSocketFloatDistance)

Rotation

Vector sub class (NodeSocketVectorEuler)

xyz

Vector sub class (NodeSocketVectorXYZ)

Translation

Vector sub class (NodeSocketVectorTranslation)

These additional values allow to enter angle, distance, factor… as group input values.

get_blender_socket()

Returns the property bsocket.

Returns

self.bsocket

Return type

bpy.types.NodeSocket

static get_class_name(socket, with_sub_class=False)

Get the DataSocket class name corresponding to the socket type and name.

Parameters
  • socket – The socket to determine the class of

  • with_sub_class (bool) – Return the sub class if True

Typ socket

bpy.types.NodeSocket, Socket

Returns

The name of the class associated to the bl_idname of the socket

Return type

str

Correspondance table

NodeSocket

class name

sub class name

NodeSocketBool

‘Boolean’

NodeSocketInt

‘Integer’

NodeSocketIntUnsigned

‘Integer’

‘Unsigned’

NodeSocketFloat

‘Float’

NodeSocketFloatFactor

‘Float’

‘Factor’

NodeSocketFloatAngle

‘Float’

‘Angle’

NodeSocketFloatDistance

‘Float’

‘Distance’

NodeSocketVector

‘Vector’

NodeSocketVectorEuler

‘Vector’

‘Rotation’

NodeSocketVectorXYZ

‘Vector’

‘xyz’

NodeSocketVectorTranslation

‘Vector’

‘Translation’

NodeSocketColor

‘Color’

NodeSocketString’

‘String’

NodeSocketCollection

‘Collection’

NodeSocketImage

‘Image’

NodeSocketMaterial

‘Material’

NodeSocketObject

‘Object’

NodeSocketTexture

‘Texture’

NodeSocketGeometry

‘Geometry’

If the name of the socket is in [‘Mesh’, ‘Points’, ‘Instances’, ‘Volume’, ‘Spline’, ‘Curve’], the name is chosen as the class name.

static gives_bsocket(value)

Test if the argument provides a valid output socket.

Parameters

value (any) – The value to test

Returns

True if value is or wraps a socket

Return type

bool

Returns True if value is:

  • A Blender Geometry Node Socket

  • An instance of Socket

info(separate_children=None, reset_children=None, transform_space='ORIGINAL', node_label=None, node_color=None)

Geometry node [Collection Info].

Parameters
  • separate_children – Boolean

  • reset_children – Boolean

  • transform_space (str) – ‘ORIGINAL’ in [ORIGINAL, RELATIVE]

  • node_label (str) – Node label

  • node_color (color) – Node background color

Returns

Geometry

Node creation

Node CollectionInfo

Blender reference : GeometryNodeCollectionInfo, Node ‘Collection Info’

from geonodes import nodes
nodes.CollectionInfo(collection=self, separate_children=separate_children, reset_children=reset_children, transform_space=transform_space, label=node_label, node_color=node_color)
init_domains()

Initialize the geometry domains

To be overloaded by sub classes.

init_socket()

Complementary init

Called at the end of initialization for further operations.

property is_multi_input

Shortcut for self.bsocket.is_multi_output

property is_output

Shortcut for self.bsocket.is_output

static is_socket(value)

An alternative to isinstance(value, Socket)

Parameters

value (any) – The value to test

Returns

True if value is an instance of Socket

Return type

bool

Shortcut for self.bsocket.links

property name

Shortcut for self.bsocket.name

node

The owning node

property node_chain_label

Shortcut for self.node.chain_label

plug(*values)

Plug values in the socket (input sockets only)

Parameters

values (array of bpy.types.NodeSocket, Socket, values) – The output sockets. More than one values can be passed if the input socket is multi input.

see plug_bsocket()

static plug_bsocket(bsocket, *values)

Plug the values to the input Blender socket.

Parameters
  • bsocket (bpy.types.NodeSocket, Socket) – The input socket to plug into

  • values (array of bpy.types.NodeSocket, Socket, values) – The output sockets. More than one values can be passed if the input socket is multi input.

Warning

bsocket must be an input socket and values must be output sockets-like.

This static method is called by the DataClass method plug().

This method is the one which links an output socket of a node to the input socket of another one.

If the socket is multi input, the plug method is called once per provided value. If a value is None, nothing happens.

A not None value can be:

  • either a valid value for the socket (eg: 123 for Integer socket)

  • or an output socket of another Node

When it is a socket, it can be a Blender socket or a DataSocket

reroute()

Reroute all output links

reset_properties()

Reset the properties

Properties such as components are cached.

After a node is called, the wrapped socket changes and this makes the cache obsolete. After a change, the cache is erased.

Example

class Vector(...):
    def __init__(self, ...):
         ...
         self.reset_properties()
         ...

     def reset_properties(self):
         super().reset_properties()
         self.separate_ = None      # Created by property self.seperate() with node SeparateXyz
property socket_index

Return the index of the socket within the list of node sockets.

Depending on the _is_output_ property, the socket belongs either to node.inputs or node.outputs.

stack(node)

Change the wrapped socket

Parameters

node (Node) – The new node owning the output socket to wrap

Returns

self

Methods are implemented in two modes:

  • Creation

  • Transformation

In creation mode, the node is considered as creating new data. The result is a new instance of DataSocket.

In transformation mode, the node is considered as transforming data which is kept in the result of the method. After the method returns, the calling DataSocket instance refers to a new Blender output socket. The stack method changes the socket the instance refers to and reinitialize properties

# 1. Creation mode
#
# to_mesh method creates a new mesh from a curve.
# The curve instance refers to the same output node socket
# We need to get the result of the method in a new variable

new_mesh = curve.to_mesh(profile_curve=circle)

# 2. Transformation mode
#
# set_shade_smooth method transforms the mesh.
# After the call, the mesh instance refers to the output socket of the
# newly created node "Set Shade Smooth". There is no need to get the result
# of the method.

mesh.set_shade_smooth()

# Note that a transformation method returns self and so, the following line
# is equivallent:

mesh = mesh.set_shade_smooth()
switch(switch=None, true=None, node_label=None, node_color=None)

Geometry node [Switch].

Parameters
  • switch – Boolean

  • true – Collection

  • node_label (str) – Node label

  • node_color (color) – Node background color

Returns

Collection

Node creation

Node Switch

  • input_type = ‘COLLECTION’

Blender reference : GeometryNodeSwitch, Node ‘Switch’

from geonodes import nodes
nodes.Switch(false=self, switch=switch, true=true, input_type='COLLECTION', label=node_label, node_color=node_color)
to_output(name=None)

Plug the data socket to the group output

Parameters

name (str) – The name to give to the modifier output

The socket is added to the outputs of the geometry nodes tree.

Note

To define a data socket as the result geometry of the tree, use tree.output_geometry = my_geometry.

view()

Link the data socket to the viewer

If the data socket is a geometry (Curve, Mesh…) it is linked to the geometry input of the viewer.

If it ias a value (Integer, Float,…) it is linked to the value socket and the viewer is configured accordingly.