BlendData(bpy_struct)

base class — bpy_struct

class bpy.types.BlendData(bpy_struct)

Main data structure representing a .blend file and all its data-blocks

actions

Action data-blocks (default None, readonly)

Type:

BlendDataActions[Action]

annotations

Annotation data-blocks (legacy Grease Pencil) (default None, readonly)

Type:

BlendDataAnnotations[Annotation]

armatures

Armature data-blocks (default None, readonly)

Type:

BlendDataArmatures[Armature]

brushes

Brush data-blocks (default None, readonly)

Type:

BlendDataBrushes[Brush]

cache_files

Cache Files data-blocks (default None, readonly)

Type:

BlendDataCacheFiles[CacheFile]

cameras

Camera data-blocks (default None, readonly)

Type:

BlendDataCameras[Camera]

collections

Collection data-blocks (default None, readonly)

Type:

BlendDataCollections[Collection]

colorspace

Information about the color space used for data-blocks in a blend file (readonly, never None)

Type:

BlendFileColorspace

curves

Curve data-blocks (default None, readonly)

Type:

BlendDataCurves[Curve]

filepath

Path to the .blend file (default “”, readonly, never None)

Type:

str

fonts

Vector font data-blocks (default None, readonly)

Type:

BlendDataFonts[VectorFont]

grease_pencils

Grease Pencil data-blocks (default None, readonly)

Type:

BlendDataGreasePencilsV3[GreasePencil]

hair_curves

Hair curve data-blocks (default None, readonly)

Type:

BlendDataHairCurves[Curves]

images

Image data-blocks (default None, readonly)

Type:

BlendDataImages[Image]

is_dirty

Have recent edits been saved to disk (default False, readonly)

Type:

bool

is_saved

Has the current session been saved to disk as a .blend file (default False, readonly)

Type:

bool

lattices

Lattice data-blocks (default None, readonly)

Type:

BlendDataLattices[Lattice]

libraries

Library data-blocks (default None, readonly)

Type:

BlendDataLibraries[Library]

lightprobes

Light Probe data-blocks (default None, readonly)

Type:

BlendDataProbes[LightProbe]

lights

Light data-blocks (default None, readonly)

Type:

BlendDataLights[Light]

linestyles

Line Style data-blocks (default None, readonly)

Type:

BlendDataLineStyles[FreestyleLineStyle]

masks

Masks data-blocks (default None, readonly)

Type:

BlendDataMasks[Mask]

materials

Material data-blocks (default None, readonly)

Type:

BlendDataMaterials[Material]

meshes

Mesh data-blocks (default None, readonly)

Type:

BlendDataMeshes[Mesh]

metaballs

Metaball data-blocks (default None, readonly)

Type:

BlendDataMetaBalls[MetaBall]

movieclips

Movie Clip data-blocks (default None, readonly)

Type:

BlendDataMovieClips[MovieClip]

node_groups

Node group data-blocks (default None, readonly)

Type:

BlendDataNodeTrees[NodeTree]

objects

Object data-blocks (default None, readonly)

Type:

BlendDataObjects[Object]

paint_curves

Paint Curves data-blocks (default None, readonly)

Type:

BlendDataPaintCurves[PaintCurve]

palettes

Palette data-blocks (default None, readonly)

Type:

BlendDataPalettes[Palette]

particles

Particle data-blocks (default None, readonly)

Type:

BlendDataParticles[ParticleSettings]

pointclouds

Point cloud data-blocks (default None, readonly)

Type:

BlendDataPointClouds[PointCloud]

scenes

Scene data-blocks (default None, readonly)

Type:

BlendDataScenes[Scene]

screens

Screen data-blocks (default None, readonly)

Type:

BlendDataScreens[Screen]

shape_keys

Shape Key data-blocks (default None, readonly)

Type:

bpy_prop_collection[Key]

sounds

Sound data-blocks (default None, readonly)

Type:

BlendDataSounds[Sound]

speakers

Speaker data-blocks (default None, readonly)

Type:

BlendDataSpeakers[Speaker]

texts

Text data-blocks (default None, readonly)

Type:

BlendDataTexts[Text]

textures

Texture data-blocks (default None, readonly)

Type:

BlendDataTextures[Texture]

use_autopack

Automatically pack all external data into .blend file (default False)

Type:

bool

version

File format version the .blend file was saved with (array of 3 items, in [0, inf], default (0, 0, 0), readonly)

Type:

bpy_prop_array[int]

volumes

Volume data-blocks (default None, readonly)

Type:

BlendDataVolumes[Volume]

window_managers

Window manager data-blocks (default None, readonly)

Type:

BlendDataWindowManagers[WindowManager]

workspaces

Workspace data-blocks (default None, readonly)

Type:

BlendDataWorkSpaces[WorkSpace]

worlds

World data-blocks (default None, readonly)

Type:

BlendDataWorlds[World]

pack_linked_ids_hierarchy(root_id)

Pack the given linked ID and its dependencies into current blendfile

Parameters:

root_id (ID) – Root linked ID to pack

Returns:

The packed ID matching the given root ID

Return type:

ID

batch_remove(ids)

Remove (delete) several IDs at once.

Note that this function is quicker than individual calls to remove() (from bpy.types.BlendData ID collections), but less safe/versatile (it can break Blender, e.g. by removing all scenes…).

Parameters:

ids (Sequence[bpy.types.ID]) – Sequence of IDs (types can be mixed).

classmethod bl_rna_get_subclass(id, default=None, /)
Parameters:
  • id (str) – The RNA type identifier.

  • default (bpy.types.Struct | None) – The value to return when not found.

Returns:

The RNA type or default when not found.

Return type:

bpy.types.Struct

classmethod bl_rna_get_subclass_py(id, default=None, /)
Parameters:
  • id (str) – The RNA type identifier.

  • default (type | None) – The value to return when not found.

Returns:

The class or default when not found.

Return type:

type

file_path_foreach(visit_path_fn, *, subset=None, visit_types=None, flags={'SKIP_PACKED', 'SKIP_WEAK_REFERENCES'})

Call visit_path_fn for the file paths used by all ID data-blocks in current bpy.data.

For list of valid set members for visit_types, see: bpy.types.KeyingSetPath.id_type.

Parameters:
  • visit_path_fn (Callable[[bpy.types.ID, str, Any], str|None]) – function that takes three parameters: the data-block, a file path, and a placeholder for future use. The function should return either None or a str. In the latter case, the visited file path will be replaced with the returned string.

  • subset (set[str] | None) – When given, only these data-blocks and their used file paths will be visited.

  • visit_types (set[str] | None) – When given, only visit data-blocks of these types. Ignored if subset is also given.

  • flags (set[str]) – Set of flags that influence which data-blocks are visited. See File Path Foreach Flag Items.

file_path_map(*, subset=None, key_types=None, include_libraries=False)

Returns a mapping of all ID data-blocks in current bpy.data to a set of all file paths used by them.

For list of valid set members for key_types, see: bpy.types.KeyingSetPath.id_type.

Parameters:
  • subset (Sequence[bpy.types.ID] | None) – When given, only these data-blocks and their used file paths will be included as keys/values in the map.

  • key_types (set[str] | None) – When given, filter the keys mapped by ID types. Ignored if subset is also given.

  • include_libraries (bool) – Include library file paths of linked data. False by default.

Returns:

dictionary of bpy.types.ID instances, with sets of file path strings as their values.

Return type:

dict[bpy.types.ID, set[str]]

orphans_purge()

Remove (delete) all IDs with no user.

Parameters:
  • do_local_ids (bool, optional) – Include unused local IDs in the deletion, defaults to True

  • do_linked_ids (bool, optional) – Include unused linked IDs in the deletion, defaults to True

  • do_recursive (bool, optional) – Recursively check for unused IDs, ensuring no orphaned one remain after a single run of that function, defaults to False

Returns:

The number of deleted IDs.

Return type:

int

static temp_data(*, filepath=None)

A context manager that temporarily creates blender file data.

Parameters:

filepath (str | bytes | None) – The file path for the newly temporary data. When None, the path of the currently open file is used.

Returns:

Blend file data which is freed once the context exits.

Return type:

bpy.types.BlendData

user_map(*, subset=None, key_types=None, value_types=None)

Returns a mapping of all ID data-blocks in current bpy.data to a set of all data-blocks using them.

For list of valid set members for key_types & value_types, see: bpy.types.KeyingSetPath.id_type.

Parameters:
  • subset (Sequence[bpy.types.ID] | None) – When passed, only these data-blocks and their users will be included as keys/values in the map.

  • key_types (set[str] | None) – Filter the keys mapped by ID types.

  • value_types (set[str] | None) – Filter the values in the set by ID types.

Returns:

dictionary that maps data-blocks ID’s to their users.

Return type:

dict[bpy.types.ID, set[bpy.types.ID]]

Inherited Properties

Inherited Functions

References