geometry_nodes package

Submodules

geometry_nodes.bl_utils module

blender_importer(module_name)
clean_up(avoid_keys=[])

Cleans up the Blender scene by removing various data types except those specified in the avoid list.

Parameters:

avoid_keys (list, optional) – A list of keys (names) to avoid deleting. Defaults to an empty list.

get_obj_min_z(obj)

Calculates the minimum Z-coordinate of an object in global space.

Parameters:

obj (bpy.types.Object) – The Blender object to calculate the minimum Z-coordinate for.

Returns:

The minimum Z-coordinate of the object.

Return type:

float

import_bpy()
init_camera()

Initializes and positions a camera in the Blender scene pointing towards the origin.

init_lights(sun_energy=3.5)

Initializes lighting in the Blender scene with a SUN light type.

Parameters:

sun_energy (float, optional) – The energy level of the sun light. Defaults to 3.5.

render_with_rotation(xy_size, number_frames, save_loc)

Renders the scene with the camera rotating around the origin.

Parameters:
  • xy_size (float) – The distance of the camera from the origin in the XY plane.

  • number_frames (int) – The number of frames to render, dictating the rotation increment.

  • save_loc (str) – The location to save the rendered images.

set_render_settings(resolution=1024, shadow_catch=False, shadow_catcher_z=-1, transparent_mode=True, line_thickness=0.25)

Configures render settings in the Blender scene.

Parameters:
  • resolution (int, optional) – The resolution for rendering. Defaults to 1024.

  • shadow_catch (bool, optional) – Flag to add a shadow catcher plane. Defaults to False.

  • shadow_catcher_z (float, optional) – Z-coordinate for the shadow catcher plane. Defaults to -1.

  • transparent_mode (bool, optional) – Enables or disables transparent mode. Defaults to True.

  • line_thickness (float, optional) – Thickness of the lines in the render. Defaults to 0.25.

geometry_nodes.evaluate_graph module

expr_to_geonode_graph(expression: GLFunction, dummy_obj, device, create_material=True, colors=None, material_type='base')

Converts a geometric expression into a Blender geometry node graph. Currently, this function only supports the NoParam 2D/3D Primitives, and basic boolean/transform operations.

Parameters:
  • expression (GLFunction) – The geometric expression to be converted into a node graph.

  • dummy_obj (bpy.types.Object) – The Blender object to which the node graph will be attached.

  • device – The device used for any necessary computations (e.g., resolving macros).

  • create_material (bool, optional) – Whether to create materials for the geometry. Defaults to True.

  • colors (list, optional) – A list of colors to be used for the materials. If None, BASE_COLORS is used. Defaults to None.

  • material_type (str, optional) – Specifies the type of material to be created. Options are “base”, “simple”, “with_edge”, “monotone”. Defaults to “base”.

Returns:

The newly created geometry node tree.

Return type:

bpy.types.NodeTree

Raises:

ValueError – If an unknown expression type is encountered.

geometry_nodes.geonodes module

create_boolean_difference_node_seq(node_group)

Creates a sequence of nodes for performing a boolean difference operation.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list containing the boolean difference node.

Return type:

list

create_boolean_intersection_node_seq(node_group)

Creates a sequence of nodes for performing a boolean intersection operation.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list containing the boolean intersection node.

Return type:

list

create_boolean_join_node_seq(node_group)

Creates a sequence of nodes for joining multiple geometries.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list containing the join geometry node.

Return type:

list

create_boolean_union_node_seq(node_group)

Creates a sequence of nodes for performing a boolean union operation.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list containing the boolean union node.

Return type:

list

create_cuboid_node_seq(node_group)

Creates a sequence of nodes for generating a cuboid geometry.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list of created nodes in the sequence.

Return type:

list

create_cylinder_node_seq(node_group)

Creates a sequence of nodes for generating a cylinder geometry.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list of created nodes in the sequence.

Return type:

list

create_geonode_tree(dummy_obj, mod_name='CSG-GN', group_name='CSG-GN')

Creates a new geometry node tree and attaches it to a given object.

Parameters:
  • dummy_obj (bpy.types.Object) – The Blender object to attach the node tree to.

  • mod_name (str, optional) – Name of the modifier to be used. Defaults to ‘CSG-GN’.

  • group_name (str, optional) – Name of the new node group. Defaults to ‘CSG-GN’.

Returns:

The newly created node tree.

Return type:

bpy.types.NodeTree

create_prebaked_primitive_node_seq(node_group, filepath)

Creates a sequence of nodes for using a prebaked mesh from a file.

Parameters:
  • node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

  • filepath (str) – File path to the mesh file.

Returns:

A list of created nodes in the sequence.

Return type:

list

create_reflect_node_seq(node_group)

Creates a sequence of nodes for reflecting a geometry.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list of created nodes in the sequence including the reflect operation.

Return type:

list

create_sphere_node_seq(node_group)

Creates a sequence of nodes for generating a sphere geometry.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list of created nodes in the sequence.

Return type:

list

create_transform_node_seq(node_group)

Creates a sequence of nodes for applying transformations to a geometry.

Parameters:

node_group (bpy.types.NodeTree) – The node tree to which the nodes will be added.

Returns:

A list containing the transform node.

Return type:

list

geometry_nodes.materials module

class colorObj(RGBA, H=0.5, S=1.0, V=1.0, B=0.0, C=0.0)

Bases: object

Represents a color object with various color properties.

Parameters:
  • RGBA (tuple) – The RGBA color values.

  • H (float, optional) – Hue component of the color. Defaults to 0.5.

  • S (float, optional) – Saturation component of the color. Defaults to 1.0.

  • V (float, optional) – Value (brightness) component of the color. Defaults to 1.0.

  • B (float, optional) – Additional brightness factor. Defaults to 0.0.

  • C (float, optional) – Contrast factor of the color. Defaults to 0.0.

create_edge_material_tree(material_name, mesh_color, edge_thickness=0.001, edge_color=(0, 0, 0), ao_strength=1.0)

Creates a material node tree with edge highlighting and ambient occlusion.

Parameters:
  • material_name (str) – Name of the new material.

  • mesh_color (tuple) – RGB color values for the mesh.

  • edge_thickness (float, optional) – Thickness of the edges. Defaults to 0.001.

  • edge_color (tuple, optional) – RGB color values for the edges. Defaults to black.

  • ao_strength (float, optional) – Strength of the ambient occlusion effect. Defaults to 1.0.

Returns:

The newly created Blender material.

Return type:

bpy.types.Material

create_material_tree(material_name, color)

Creates a complex material node tree for the renders in CoReF paper (ICCV 2023).

Parameters:
  • material_name (str) – Name of the new material.

  • color (tuple) – RGB color values for the material.

Returns:

The newly created Blender material.

Return type:

bpy.types.Material

create_monotone_material(material_name, mesh_color, color_list, silhouette_color, shadow_size=0.1)

Creates a monotone material with multiple color levels, silhouette, and shadow effects.

Parameters:
  • material_name (str) – Name of the new material.

  • mesh_color (tuple) – RGB color values for the mesh.

  • color_list (list) – List of RGB color tuples for different color levels.

  • silhouette_color (tuple) – RGB color values for the silhouette effect.

  • shadow_size (float, optional) – Size of the shadow effect. Defaults to 0.1.

Returns:

The newly created Blender material.

Return type:

bpy.types.Material

create_simple_material_tree(material_name, color)

Creates a simple material node tree suitable for .gltf exports.

Parameters:
  • material_name (str) – Name of the new material.

  • color (tuple) – RGB color values for the material.

Returns:

The newly created Blender material.

Return type:

bpy.types.Material

geometry_nodes.utils module