blenderproc.python.utility.BlenderUtility module
This module provides a collection of utility functions tied closely to Blender.
- blenderproc.python.utility.BlenderUtility.add_cube_based_on_bb(bouding_box, name='NewCube')[source]
Generates a cube based on the given bounding box, the bounding_box can be generated with our get_bounds(obj) fct.
- Parameters:
bounding_box – bound_box [8x[3xfloat]], with 8 vertices for each corner
name (
str
) – name of the new cube
- Return type:
Object
- Returns:
the generated object
- blenderproc.python.utility.BlenderUtility.add_group_nodes(group)[source]
Adds the group input and output node and positions them correctly.
- Parameters:
group (
ShaderNodeTree
) – the group which will get an output and input node- Return bpy.types.NodeGroupInput, bpy.types.NodeGroupOutput:
the input and output to the given group
- Return type:
Tuple
[Node
,Node
]
- blenderproc.python.utility.BlenderUtility.add_nodes_to_group(nodes, group_name)[source]
Creates the node group, copies all attributes and links and adds the group input and output https://blender.stackexchange.com/a/175604
- Parameters:
nodes (
Node
) – Nodes, which should be usedgroup_name (
str
) – Name of the group
- Return type:
ShaderNodeTree
- Returns:
bpy.types.ShaderNodeTree: the group which can be used inside of a bpy.types.ShaderNodeGroup
- blenderproc.python.utility.BlenderUtility.add_object_only_with_direction_vectors(vertices, normals, radius=1.0, name='NewDirectionObject')[source]
Generates a new object with the given vertices and normals, there will be an edge between each point and the point plus the normal times the radius. No faces are generated.
- Parameters:
vertices (
List
[List
[float
]]) – [[float, float, float]] list of verticesnormals (
List
[List
[float
]]) – [[float, float, float]] list of normalsradius (
float
) – Determines the size of the edge generatedname (
str
) – str name of the new object
- Return type:
Object
- Returns:
the generated obj
- blenderproc.python.utility.BlenderUtility.add_object_only_with_vertices(vertices, name='NewVertexObject')[source]
Generates a new object with the given vertices, no edges or faces are generated.
- Parameters:
vertices (
List
[List
[float
]]) – [[float, float, float]] list of verticesname (
str
) – str name of the new object
- Return type:
Object
- Returns:
the generated obj
- blenderproc.python.utility.BlenderUtility.collect_all_orphan_data_blocks()[source]
Returns all orphan data blocks grouped by their type
- Return type:
Dict
[str
,Any
]- Returns:
A dict of sets
- blenderproc.python.utility.BlenderUtility.copy_attributes(attributes, old_prop, new_prop)[source]
Copies the list of attributes from the old to the new prop if the attribute exists.
- Param:
attributes: Current selected attributes
- Param:
old_prop: Old property
- Param:
new_prop: New property
- blenderproc.python.utility.BlenderUtility.copy_links(nodes, goal_nodes, goal_links)[source]
Copies all links between the nodes to goal_links with the goal_nodes.
- Parameters:
nodes (
Nodes
) – Nodes, which are used as base for the copyinggoal_nodes (
Nodes
) – Nodes, which are will be newly connectedgoal_links (
NodeLinks
) – Links, where all the newly generated links are saved
- blenderproc.python.utility.BlenderUtility.copy_nodes(nodes, goal_nodes)[source]
Copies all nodes from the given list into the group with their attributes
- Param:
node: the nodes which should be copied
- Param:
goal_nodes: the nodes where they should be copied too
- blenderproc.python.utility.BlenderUtility.copy_nodes_from_mat_to_material(from_material, to_material)[source]
Copy nodes from one material to another material
- Parameters:
from_material (
Material
) – The material from which the nodes are selectedto_material (
Material
) – The material to which the nodes will be copied
- blenderproc.python.utility.BlenderUtility.get_all_blender_mesh_objects()[source]
Returns a list of all mesh objects in the scene :rtype:
List
[Object
] :return: a list of all mesh objects
- blenderproc.python.utility.BlenderUtility.get_all_materials()[source]
Returns a list of all materials used and unused :rtype:
List
[Material
] :return: a list of all materials
- blenderproc.python.utility.BlenderUtility.get_all_textures()[source]
Returns a list of all textures. :rtype:
List
[Texture
] :return: All textures. Type: list.
- blenderproc.python.utility.BlenderUtility.get_node_attributes(node)[source]
Returns a list of all properties identifiers if they should not be ignored
- Param:
node: the node which attributes should be returned
- Return type:
List
[str
]- Returns:
list of attributes of the given node
- blenderproc.python.utility.BlenderUtility.load_image(file_path, num_channels=3)[source]
Load the image at the given path returns its pixels as a numpy array.
The alpha channel is neglected.
- Parameters:
file_path (
str
) – The path to the image.num_channels (
int
) – Number of channels to return.
- Return type:
ndarray
- Returns:
The numpy array