blenderproc.python.loader.BlendLoader module

Loading the content of .blend files

class blenderproc.python.loader.BlendLoader._BlendLoader[source]

Bases: object

static purge_added_orphans(orphans_before, data_to)[source]

Removes all orphans that did not exists before loading the blend file.

Parameters:
  • orphans_before – A dict of sets containing orphans of all kind of data_blocks that existed before loading the blend file.

  • data_to – The list of objects that were loaded on purpose and should not be removed, even when they are orphans.

valid_data_blocks = ['actions', 'armatures', 'brushes', 'cache_files', 'cameras', 'collections', 'curves', 'fonts', 'grease_pencils', 'hair_curves', 'images', 'lattices', 'libraries', 'lightprobes', 'lights', 'linestyles', 'masks', 'materials', 'meshes', 'metaballs', 'movieclips', 'node_groups', 'objects', 'paint_curves', 'palettes', 'particles', 'pointclouds', 'scenes', 'screens', 'shape_keys', 'sounds', 'speakers', 'texts', 'textures', 'volumes', 'window_managers', 'workspaces', 'worlds']
valid_object_types = ['mesh', 'curve', 'surface', 'meta', 'font', 'hair', 'pointcloud', 'volume', 'gpencil', 'armature', 'lattice', 'empty', 'light', 'light_probe', 'camera', 'speaker']
static validate_and_standardizes_configured_list(config_value, allowed_elements, element_name)[source]

Makes sure the given config value is a list, is lower case and only consists of valid elements.

Parameters:
  • config_value (Union[list, str]) – The configured value that should be standardized and validated.

  • allowed_elements (list) – A list of valid elements. If one configured element is not contained in this list an exception is thrown.

  • element_name (str) – How one element is called. Used to create an error message.

Return type:

list

Returns:

The standardized and validated config value.

blenderproc.python.loader.BlendLoader.load_blend(path, obj_types=None, name_regrex=None, data_blocks='objects', link=False)[source]

Loads entities (everything that can be stored in a .blend file’s folders, see Blender’s documentation for bpy.types.ID for more info) that match a name pattern from a specified .blend file’s section/data_block.

Parameters:
  • path (str) – Path to a .blend file.

  • obj_types (Union[List[str], str, None]) – The type of objects to load. This parameter is only relevant when data_blocks is set to “objects”. Available options are: [‘mesh’, ‘curve’, ‘hair’, ‘armature’, ‘empty’, ‘light’, ‘camera’]

  • name_regrex (Optional[str]) – Regular expression representing a name pattern of entities’ (everything that can be stored in a .blend file’s folders, see Blender’s documentation for bpy.types.ID for more info) names.

  • data_blocks (Union[List[str], str]) – The data block or a list of data blocks which should be loaded from the given .blend file. Available options are: [‘armatures’, ‘cameras’, ‘curves’, ‘hairs’, ‘images’, ‘lights’, ‘materials’, ‘meshes’, ‘objects’, ‘textures’]

  • link (bool) – whether to link instead of append data blocks from .blend file. Linked objects can not be modified.

Return type:

List[Entity]

Returns:

The list of loaded mesh objects.