Class Domain#

Domain is the root class for:

  • Vertex, node domain ‘POINT’

  • Edge, node domain ‘EDGE’

  • Face, node domain ‘FACE’

  • Corner, node domain ‘CORNER’

  • ControlPoint, node domain ‘POINT’

  • Spline, node domain *’SPLINE’ (or ‘CURVE’)

  • CloudPoint, node domain ‘POINT’

  • Instance, node domain ‘INSTANCE’

Domain provides mechanism to keep the context, by maintaining:

  • the selection

  • the node domain value in ‘POINT’, ‘EDGE’, ‘FACE’, ‘CORNER’, ‘SPLINE’, ‘INSTANCE’

  • the geometry it is a domain of

By keeping the context geometry, it is not necessary to explicitly create Capture Attribute. Domain class determines if it is necessary or not to create this node.

Domains are not initialized directly but by geometries:

Note that the node domain ‘POINT’ is used by 3 Domains.

Selection mechanism#

One important feature of Domain is the selection mechanism. The selection is expressed using the array syntax:

  • mesh.verts[1] : select the index == 1

  • mesh.faces[10:20] : select the index in the range 10 to 20 (exc)

  • mesh.faces[8, 17] : select the index equal to 8 or 17

  • mesh.edges[(mesh.edges.index % 2).equal(0)] : select the even index

Nodes having a Selection socket use the Domain selection initialized with this syntax.

In the following example, two vertices selected by the user are move upwards:

import geonodes as gn

with gn.Tree("Test") as tree:
    
    index1 = gn.Integer.Input(0, "Index 1")
    index2 = gn.Integer.Input(1, "Index 2")
    
    cube = gn.Mesh.Cube()
    
    cube.verts[index1, index2].position += (0, 0, .2)
    
    tree.og = cube

Constructor#

Domain(self, data_socket, selection=None)

Args:#

  • data_socket (DataSocket): the data class the domain belongs to

  • selection (any): the selection to use

Content#

Properties

ID | as_cloud_points | as_control_points | as_corners | as_edges | as_faces | as_insts | as_splines | as_verts | data_socket | domain | domain_index | index | normal | position | selection | selection_index

Class and static methods

random_boolean | random_float | random_integer | random_vector

Methods

accumulate_field | attribute_max | attribute_mean | attribute_median | attribute_min | attribute_node | attribute_range | attribute_statistic | attribute_std | attribute_sum | attribute_var | capture_attribute | field_at_index | index_for_sample | interpolate | material_selection | named_attribute | named_boolean | named_color | named_float | named_integer | named_vector | remove_named_attribute | sample_index | select | set_ID | set_position | socket_stack | store_named_attribute | store_named_attribute_no_selection | store_named_boolean | store_named_color | store_named_float | store_named_integer | store_named_vector | view | viewer

Properties#

ID#

Returns:#

  • socket ID

Setter

Node implemented as property setter.

Args:#

  • attr_value: ID

Go to top - main - nodes - nodes menus

as_cloud_points#

Type cast to CloudPoint.

Go to top - main - nodes - nodes menus

as_control_points#

Type cast to ControlPoint.

Go to top - main - nodes - nodes menus

as_corners#

Type cast to Corner.

Go to top - main - nodes - nodes menus

as_edges#

Type cast to Edge.

Go to top - main - nodes - nodes menus

as_faces#

Type cast to Face.

Go to top - main - nodes - nodes menus

as_insts#

Type cast to Instance.

Go to top - main - nodes - nodes menus

as_splines#

Type cast to Spline.

Go to top - main - nodes - nodes menus

as_verts#

Type cast to Vertex.

Go to top - main - nodes - nodes menus

data_socket#

Returns the data socket it belongs to.

Returns:#

  • DataSocket

Go to top - main - nodes - nodes menus

domain#

Gives the Geometry Nodes domain string to use in the generated nodes.

  • Vertex : ‘POINT’,

  • Edge : ‘EDGE’,

  • Face : ‘FACE’,

  • Corner : ‘CORNER’,

  • ControlPoint : ‘POINT’,

  • Spline : ‘CURVE’,

  • CloudPoint : ‘POINT’,

  • Instance : ‘INSTANCE’,

Returns:#

  • domain string (str)

Go to top - main - nodes - nodes menus

domain_index#

Returns:#

  • socket index

Go to top - main - nodes - nodes menus

index#

Returns:#

  • socket index

Go to top - main - nodes - nodes menus

normal#

Returns:#

  • socket normal

Go to top - main - nodes - nodes menus

position#

Returns:#

  • socket position

Setter

Node implemented as property setter.

Args:#

  • attr_value: position

Go to top - main - nodes - nodes menus

selection#

Returns the selection value to use in nodes with a Selection socket.

Returns:#

  • Boolean

Go to top - main - nodes - nodes menus

selection_index#

Returns the selection index.

CAUTION: raise an error if the selection is not a integer.

Returns:#

  • Integer

Go to top - main - nodes - nodes menus

Class and static methods#

random_boolean#

@staticmethod
def random_boolean(probability=None, ID=None, seed=None)

Args:#

  • probability: Float

  • ID: Integer

  • seed: Integer

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

random_float#

@staticmethod
def random_float(min=None, max=None, ID=None, seed=None)

Args:#

  • min: [‘Vector’, ‘Float’, ‘Integer’]

  • max: [‘Vector’, ‘Float’, ‘Integer’]

  • ID: Integer

  • seed: Integer

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

random_integer#

@staticmethod
def random_integer(min=None, max=None, ID=None, seed=None)

Args:#

  • min: [‘Vector’, ‘Float’, ‘Integer’]

  • max: [‘Vector’, ‘Float’, ‘Integer’]

  • ID: Integer

  • seed: Integer

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

random_vector#

@staticmethod
def random_vector(min=None, max=None, ID=None, seed=None)

Args:#

  • min: [‘Vector’, ‘Float’, ‘Integer’]

  • max: [‘Vector’, ‘Float’, ‘Integer’]

  • ID: Integer

  • seed: Integer

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

Methods#

accumulate_field#

def accumulate_field(self, value=None, group_index=None)

Args:#

  • value: [‘Vector’, ‘Float’, ‘Integer’]

  • group_index: Integer

Node Image

Returns:#

  • tuple (’leading’, ‘trailing’, ‘total’)

Go to top - main - nodes - nodes menus

attribute_max#

def attribute_max(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket max

Go to top - main - nodes - nodes menus

attribute_mean#

def attribute_mean(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket mean

Go to top - main - nodes - nodes menus

attribute_median#

def attribute_median(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket median

Go to top - main - nodes - nodes menus

attribute_min#

def attribute_min(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket min

Go to top - main - nodes - nodes menus

attribute_node#

def attribute_node(self, node)

Define an input node as attribute

Called when creating an input node in a property getter. Performs two actions:

- Call the method :func:`Node.as_attribute` to tag the node as being an attribute.
  This will allow the :func:`Tree.check_attributes` to see if it is necessary to create
  a *Capture Attribute* for this field.
- Set the nde property :attr:`field_of` to self in order to implement the transfer attribute
  mechanism.

Args:#

  • node (Node): The node created by the domain

Returns:#

  • The node argument

Go to top - main - nodes - nodes menus

attribute_range#

def attribute_range(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket range

Go to top - main - nodes - nodes menus

attribute_statistic#

def attribute_statistic(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • node with sockets [‘mean’, ‘median’, ‘sum’, ‘min’, ‘max’, ‘range’, ‘standard_deviation’, ‘variance’]

Go to top - main - nodes - nodes menus

attribute_std#

def attribute_std(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket standard_deviation

Go to top - main - nodes - nodes menus

attribute_sum#

def attribute_sum(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket sum

Go to top - main - nodes - nodes menus

attribute_var#

def attribute_var(self, attribute=None)

Args:#

  • attribute: [‘Float’, ‘Vector’]

Returns:#

  • socket variance

Go to top - main - nodes - nodes menus

capture_attribute#

def capture_attribute(self, value=None)

Args:#

  • value: [‘Vector’, ‘Float’, ‘Color’, ‘Boolean’, ‘Integer’]

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

field_at_index#

def field_at_index(self, index=None, value=None)

Args:#

  • index: Integer

  • value: [‘Float’, ‘Integer’, ‘Vector’, ‘Color’, ‘Boolean’]

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

index_for_sample#

def index_for_sample(self, default=None)

Return default if not None or Input index socket.

The node ‘Sample Index’ has an input with default value to 0. If mehod argument is None, create a node ‘Input Index’ as input.

sample_index method is implemented:

def sample_index(self, value=None, index=None, clamp=False):
    return nodes.SampleIndex(..., index=self.index_for_sample(index), ...)

Returns:#

  • default or Input index

Go to top - main - nodes - nodes menus

interpolate#

def interpolate(self, value=None)

Args:#

  • value: [‘Float’, ‘Integer’, ‘Vector’, ‘Color’, ‘Boolean’]

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

material_selection#

def material_selection(self, material=None)

Args:#

  • material: Material

Returns:#

  • socket selection

Go to top - main - nodes - nodes menus

named_attribute#

def named_attribute(self, name=None, data_type='FLOAT')

Args:#

  • name: String

  • data_type (str): ‘FLOAT’ in [FLOAT, INT, FLOAT_VECTOR, FLOAT_COLOR, BOOLEAN]

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

named_boolean#

def named_boolean(self, name=None)

Args:#

  • name: String

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

named_color#

def named_color(self, name=None)

Args:#

  • name: String

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

named_float#

def named_float(self, name=None)

Args:#

  • name: String

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

named_integer#

def named_integer(self, name=None)

Args:#

  • name: String

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

named_vector#

def named_vector(self, name=None)

Args:#

  • name: String

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

remove_named_attribute#

def remove_named_attribute(self, name=None)

Args:#

  • name: String

Returns:#

  • self

Go to top - main - nodes - nodes menus

sample_index#

def sample_index(self, value=None, index=None, clamp=False)

Args:#

  • value: [‘Float’, ‘Integer’, ‘Vector’, ‘Color’, ‘Boolean’]

  • index: Integer

  • clamp (bool): False

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

select#

def select(self, selection)

Select the domain

If the method is called on a Domain which already has a selection, the two selections are combined:

verts = mesh.verts[10:20] # Selection of vertices from 10 to 20
v = verts.select((verts.index % 2).equal(0)) # Even indices in the previous selection

Args:#

  • selection (Boolean or Integer): The selection condition

Returns:#

  • Domain with the given selection (Domain)

If a selection is existing, the resulting selection is a logical and betwenn the two

Go to top - main - nodes - nodes menus

set_ID#

def set_ID(self, ID=None)

Args:#

  • ID: Integer

Returns:#

  • self

Go to top - main - nodes - nodes menus

set_position#

def set_position(self, position=None, offset=None)

Args:#

  • position: Vector

  • offset: Vector

Returns:#

  • self

Go to top - main - nodes - nodes menus

socket_stack#

def socket_stack(self, node, socket_name=None)

Make the owning socket jump to the output socket of the node passed in argumment.

Args:#

  • node (Node): The node to jump to

  • socket_name: The name of the output socket (first one if None)

Go to top - main - nodes - nodes menus

store_named_attribute#

def store_named_attribute(self, name=None, value=None, data_type=None)

Store a named attribute

If selection exists, create an intermediary cloud of points to update selectively the items.

Args:#

  • name (str): name of the attribute

  • value (any): value of the attribute

  • data_type (str): valeu data type

Returns:#

  • data socket (DataSocket)

Go to top - main - nodes - nodes menus

store_named_attribute_no_selection#

def store_named_attribute_no_selection(self, name=None, value=None)

Args:#

  • name: String

  • value: [‘Vector’, ‘Float’, ‘Color’, ‘Boolean’, ‘Integer’]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_boolean#

def store_named_boolean(self, name, value)

Store a named attribute of type Boolean

see store_named_attribute

Args:#

  • name (str): the attribute name

  • value (float): the value to store

Returns:#

  • Data socket (DataSocket)

Go to top - main - nodes - nodes menus

store_named_color#

def store_named_color(self, name, value)

Store a named attribute of type Color

Args:#

  • name (str): the attribute name

  • value (float): the value to store

see store_named_attribute

Returns:#

  • Data socket (DataSocket)

Go to top - main - nodes - nodes menus

store_named_float#

def store_named_float(self, name, value)

Store a named attribute of type Float

see store_named_attribute

Args:#

  • name (str): the attribute name

  • value (float): the value to store

Returns:#

  • Data socket (DataSocket)

Go to top - main - nodes - nodes menus

store_named_integer#

def store_named_integer(self, name, value)

Store a named attribute of type Integer

see store_named_attribute

Args:#

  • name (str): the attribute name

  • value (float): the value to store

Returns:#

  • Data socket (DataSocket)

Go to top - main - nodes - nodes menus

store_named_vector#

def store_named_vector(self, name, value)

Store a named attribute of type Vector

Args:#

  • name (str): the attribute name

  • value (float): the value to store

see store_named_attribute

Returns:#

  • Data socket (DataSocket)

Go to top - main - nodes - nodes menus

view#

def view(self, value=None)

Args:#

  • value: [‘Float’, ‘Vector’, ‘Color’, ‘Integer’, ‘Boolean’]

Returns:#

  • node with sockets []

Go to top - main - nodes - nodes menus

viewer#

def viewer(self, value=None)

Args:#

  • value: [‘Float’, ‘Vector’, ‘Color’, ‘Integer’, ‘Boolean’]

Returns:#

  • node with sockets []

Go to top - main - nodes - nodes menus