Class Geometry#

Geometry DataSocket

In Blender, there is only one type of geometry socket. Sub classes Mesh, Curve, Points, Instances and Volume are introduced by geonodes. Each sub class implement the nodes creation which are specific to them.

For instance, the node ‘Extrude Mesh’ is specific to meshes. This node is implemented by the method extrude of class Mesh:

top, side = mesh.extrude()

Some Geometry sub classes can have methods with the same name but are based on different nodes:

points_1 = mesh.to_points()  # Create a 'Mesh to Points' node
points_2 = curve.to_points() # Create a 'Curve to Points' node

Initialization#

There is no constructor returnig of geometry of type Geometry. Constructors are class methods of sub classes implementing their specific primitive nodes:

cube     = Mesh.Cube()      # node 'Cube'
circle_1 = Mesh.Circle()    # node 'Mesh Circle'
circle_2 = Curve.Circle()   # node 'Curve Circle'
volume   = Volume.Cube()    # node 'Volume Cube'

Geometry is the type of the input geometry which can be read from the property input_geometry of the Tree. If a modifier is dedicated to meshes, one must type cast the input geometry to the desired type:

with Tree("Geometry Nodes") as tree:
    geometry = tree.input_geometry # class Geometry
    mesh = Mesh(tree.ig)           # type cast to Mesh (ig is the short version of input_geometry)

Components#

The components of Geometry can be accessed via dedicated properties. This is an alternative to typecasting the input geometry.

geo = tree.ig
mesh = geo.mesh_component    # Socket 'Mesh' of node 'Separate Components'
vol  = geo.volume_component  # Socket 'Volume' of node 'Separated Components'

Joining#

Geometry supports the + operator acting as method join. In the following example, the tree returns the joining of a cube and a sphere:

cube = Mesh.Cube()
sphere = Mesh.IcoSphere()
tree.output_geometry = cube + sphere

Constructor#

Geometry(self, socket, node=None, label=None)

rom geonodes.nodes import domains

elf.points = Vertex(self) # Initialized before super().init which can override points

Content#

Properties

ID | bounding_box | bounding_box_min | convex_hull | curve_component | domain_size | index | instances_component | is_viewport | material_index | mesh_component | normal | points_component | position | radius | separate_components | volume_component

Inherited

bl_idname | bnode | is_multi_input | is_output | is_plugged | links | name | node_chain_label | socket_index

Class and static methods

Collection | FromCollection | Input | capture_attribute_node | random_boolean | random_float | random_integer | random_vector

Inherited

get_bl_idname | get_class_name | gives_bsocket | is_socket | is_vector | python_type_to_socket | value_data_type

Methods

attribute_statistic | capture_attribute | delete | duplicate | field_at_index | instantiate | interpolate_domain | join | material_selection | merge_by_distance | named_attribute | named_boolean | named_color | named_float | named_integer | named_vector | proximity | proximity_edges | proximity_faces | proximity_points | raycast | raycast_interpolated | raycast_nearest | remove_named_attribute | replace_material | sample_index | sample_nearest | separate | set_ID | set_material | set_material_index | set_position | show_handles | store_named_attribute | store_named_boolean | store_named_color | store_named_float | store_named_integer | store_named_vector | switch | to_instance | transform | view | viewer

Inherited

connected_sockets | get_blender_socket | init_domains | init_socket | plug | reroute | reset_properties | stack | to_output

Properties#

ID#

Returns:#

  • socket ID

Go to top - main - nodes - nodes menus

bounding_box#

Returns:#

  • socket bounding_box of class Mesh

Go to top - main - nodes - nodes menus

bounding_box_min#

Returns:#

  • socket max

Go to top - main - nodes - nodes menus

convex_hull#

Returns:#

  • socket convex_hull of class Mesh

Go to top - main - nodes - nodes menus

curve_component#

Returns:#

  • socket curve of class Curve

Go to top - main - nodes - nodes menus

domain_size#

Returns:#

  • node with sockets [‘point_count’, ‘edge_count’, ‘face_count’, ‘face_corner_count’, ‘spline_count’, ‘instance_count’]

Go to top - main - nodes - nodes menus

index#

Returns:#

  • socket index

Go to top - main - nodes - nodes menus

instances_component#

Returns:#

  • socket instances of class Instances

Go to top - main - nodes - nodes menus

is_viewport#

Returns:#

  • socket is_viewport

Go to top - main - nodes - nodes menus

material_index#

Returns:#

  • socket material_index

Go to top - main - nodes - nodes menus

mesh_component#

Returns:#

  • socket mesh of class Mesh

Go to top - main - nodes - nodes menus

normal#

Returns:#

  • socket normal

Go to top - main - nodes - nodes menus

points_component#

Returns:#

  • socket point_cloud of class Points

Go to top - main - nodes - nodes menus

position#

Returns:#

  • socket position

Go to top - main - nodes - nodes menus

radius#

Returns:#

  • socket radius

Go to top - main - nodes - nodes menus

separate_components#

Returns:#

  • node with sockets [‘mesh’, ‘point_cloud’, ‘curve’, ‘volume’, ‘instances’]

Go to top - main - nodes - nodes menus

volume_component#

Returns:#

  • socket volume of class Volume

Go to top - main - nodes - nodes menus

Class and static methods#

Collection#

@classmethod
def Collection(cls, collection=None, separate_children=None, reset_children=None, transform_space='ORIGINAL')

Args:#

  • collection: Collection

  • separate_children: Boolean

  • reset_children: Boolean

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

Returns:#

  • socket geometry

Go to top - main - nodes - nodes menus

FromCollection#

@classmethod
def FromCollection(cls, collection=None, separate_children

Get the geometry from a collection

Go to top - main - nodes - nodes menus

Input#

@classmethod
def Input(cls, name = None, description = "")

Create a Geometry input socket in the Group Input Node

Args:#

  • name: The socket name

  • description: User tip

Returns:#

  • Geometry: The Geometry data socket

Note: This method create a new input socket in the Group Input node. To get the default input geometry, use Tree.input_geometry property.

Go to top - main - nodes - nodes menus

capture_attribute_node#

@staticmethod
def capture_attribute_node(geometry=None, value=None, data_type='FLOAT', domain='POINT')

Args:#

  • geometry: Geometry

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

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • node with sockets [‘geometry’, ‘attribute’]

Go to top - main - nodes - nodes menus

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#

attribute_statistic#

def attribute_statistic(self, selection=None, attribute=None, domain='POINT')

Args:#

  • selection: Boolean

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

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

Go to top - main - nodes - nodes menus

capture_attribute#

def capture_attribute(self, value=None, domain='POINT')

Args:#

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • socket attribute

Go to top - main - nodes - nodes menus

delete#

def delete(self, selection=None, domain='POINT', mode='ALL')

Args:#

  • selection: Boolean

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CURVE, INSTANCE]

  • mode (str): ‘ALL’ in [ALL, EDGE_FACE, ONLY_FACE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

duplicate#

def duplicate(self, selection=None, amount=None, domain='POINT')

Args:#

  • selection: Boolean

  • amount: Integer

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, SPLINE, INSTANCE]

Returns:#

  • socket duplicate_index

Go to top - main - nodes - nodes menus

field_at_index#

def field_at_index(self, index=None, value=None, domain='POINT')

Args:#

  • index: Integer

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

instantiate#

def instantiate(self, count = 1, realize = False)

Instantiate the geometry

Args:#

  • count: Number of instances to create

  • realize: True to realize the instances

Returns:#

  • Instances or Geometry

The duplication is performed by instantiating the geometry along the vertices of a Mesh Line initialized with count points.

The operator * can be used to operate this method with realize = False:

    
curves = curve * 10

# is equivalent to

curves = curve.duplicate(10, realize=False)

Go to top - main - nodes - nodes menus

interpolate_domain#

def interpolate_domain(self, value=None, domain='POINT')

Args:#

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

join#

def join(*geometry)

Args:#

  • geometry: Geometry

Returns:#

  • socket geometry

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

merge_by_distance#

def merge_by_distance(self, selection=None, distance=None, mode='ALL')

Args:#

  • selection: Boolean

  • distance: Float

  • mode (str): ‘ALL’ in [ALL, CONNECTED]

Returns:#

  • self

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

proximity#

def proximity(self, target=None, source_position=None, target_element='FACES')

Args:#

  • target: Geometry

  • source_position: Vector

  • target_element (str): ‘FACES’ in [POINTS, EDGES, FACES]

Returns:#

  • socket distance

Go to top - main - nodes - nodes menus

proximity_edges#

def proximity_edges(self, target=None, source_position=None)

Args:#

  • target: Geometry

  • source_position: Vector

Returns:#

  • socket distance

Go to top - main - nodes - nodes menus

proximity_faces#

def proximity_faces(self, target=None, source_position=None)

Args:#

  • target: Geometry

  • source_position: Vector

Returns:#

  • socket distance

Go to top - main - nodes - nodes menus

proximity_points#

def proximity_points(self, target=None, source_position=None)

Args:#

  • target: Geometry

  • source_position: Vector

Returns:#

  • socket distance

Go to top - main - nodes - nodes menus

raycast#

def raycast(self, target_geometry=None, attribute=None, source_position=None, ray_direction=None, ray_length=None, mapping='INTERPOLATED')

Args:#

  • target_geometry: Geometry

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

  • source_position: Vector

  • ray_direction: Vector

  • ray_length: Float

  • mapping (str): ‘INTERPOLATED’ in [INTERPOLATED, NEAREST]

Returns:#

  • node with sockets [‘is_hit’, ‘hit_position’, ‘hit_normal’, ‘hit_distance’, ‘attribute’]

Go to top - main - nodes - nodes menus

raycast_interpolated#

def raycast_interpolated(self, target_geometry=None, attribute=None, source_position=None, ray_direction=None, ray_length=None)

Args:#

  • target_geometry: Geometry

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

  • source_position: Vector

  • ray_direction: Vector

  • ray_length: Float

Returns:#

  • node with sockets [‘is_hit’, ‘hit_position’, ‘hit_normal’, ‘hit_distance’, ‘attribute’]

Go to top - main - nodes - nodes menus

raycast_nearest#

def raycast_nearest(self, target_geometry=None, attribute=None, source_position=None, ray_direction=None, ray_length=None)

Args:#

  • target_geometry: Geometry

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

  • source_position: Vector

  • ray_direction: Vector

  • ray_length: Float

Returns:#

  • node with sockets [‘is_hit’, ‘hit_position’, ‘hit_normal’, ‘hit_distance’, ‘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

replace_material#

def replace_material(self, old=None, new=None)

Args:#

  • old: Material

  • new: Material

Returns:#

  • self

Go to top - main - nodes - nodes menus

sample_index#

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

Args:#

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

  • index: Integer

  • clamp (bool): False

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • socket value

Go to top - main - nodes - nodes menus

sample_nearest#

def sample_nearest(self, sample_position=None, domain='POINT')

Args:#

  • sample_position: Vector

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER]

Returns:#

  • socket index

Go to top - main - nodes - nodes menus

separate#

def separate(self, selection=None, domain='POINT')

Args:#

  • selection: Boolean

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CURVE, INSTANCE]

Node Image

Returns:#

  • tuple (’selection’, ‘inverted’)

Go to top - main - nodes - nodes menus

set_ID#

def set_ID(self, selection=None, ID=None)

Args:#

  • selection: Boolean

  • ID: Integer

Returns:#

  • self

Go to top - main - nodes - nodes menus

set_material#

def set_material(self, selection=None, material=None)

Args:#

  • selection: Boolean

  • material: Material

Returns:#

  • self

Go to top - main - nodes - nodes menus

set_material_index#

def set_material_index(self, selection=None, material_index=None)

Args:#

  • selection: Boolean

  • material_index: Integer

Returns:#

  • self

Go to top - main - nodes - nodes menus

set_position#

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

Args:#

  • selection: Boolean

  • position: Vector

  • offset: Vector

Returns:#

  • self

Go to top - main - nodes - nodes menus

show_handles#

def show_handles(self)

Generate a mesh and cloud points to visualize the control points and handles

Returns:#

  • Geometry: The geometry can be joined to the output

Example:

curve = ... # Curve initialization

visu = curve.show_handles()

tree.output_geometry = curve + visu

Go to top - main - nodes - nodes menus

store_named_attribute#

def store_named_attribute(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_boolean#

def store_named_boolean(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_color#

def store_named_color(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_float#

def store_named_float(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_integer#

def store_named_integer(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

store_named_vector#

def store_named_vector(self, name=None, value=None, domain='POINT')

Args:#

  • name: String

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

  • domain (str): ‘POINT’ in [POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • self

Go to top - main - nodes - nodes menus

switch#

def switch(self, switch=None, true=None)

Args:#

  • switch: Boolean

  • true: Geometry

Returns:#

  • socket output

Go to top - main - nodes - nodes menus

to_instance#

def to_instance(*geometry)

Args:#

  • geometry: Geometry

Returns:#

  • socket instances of class Instances

Go to top - main - nodes - nodes menus

transform#

def transform(self, translation=None, rotation=None, scale=None)

Args:#

  • translation: Vector

  • rotation: Vector

  • scale: Vector

Returns:#

  • self

Go to top - main - nodes - nodes menus

view#

def view(self, value=None, domain='AUTO')

Args:#

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

  • domain (str): ‘AUTO’ in [AUTO, POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • node with sockets []

Go to top - main - nodes - nodes menus

viewer#

def viewer(self, value=None, domain='AUTO')

Args:#

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

  • domain (str): ‘AUTO’ in [AUTO, POINT, EDGE, FACE, CORNER, CURVE, INSTANCE]

Returns:#

  • node with sockets []

Go to top - main - nodes - nodes menus