bpy_prop_collection

class bpy.types.bpy_prop_collection

built-in class used for all collections.

Note

Note that bpy.types.bpy_prop_collection is not actually available from within Blender, it only exists for the purpose of documentation.

find(key)

Returns the index of a key in a collection or -1 when not found (matches Python’s string find function of the same name).

Parameters

key (string) – The identifier for the collection member.

Returns

index of the key.

Return type

int

foreach_get(attr, seq)

This is a function to give fast access to attributes within a collection.

Only works for ‘basic type’ properties (bool, int and float)! Multi-dimensional arrays (like array of vectors) will be flattened into seq.


collection.foreach_get(attr, some_seq)

# Python equivalent
for i in range(len(seq)):
    some_seq[i] = getattr(collection[i], attr)
foreach_set(attr, seq)

This is a function to give fast access to attributes within a collection.

Only works for ‘basic type’ properties (bool, int and float)! seq must be uni-dimensional, multi-dimensional arrays (like array of vectors) will be re-created from it.


collection.foreach_set(attr, some_seq)

# Python equivalent
for i in range(len(some_seq)):
    setattr(collection[i], attr, some_seq[i])
get(key, default=None)

Returns the value of the item assigned to key or default when not found (matches Python’s dictionary function of the same name).

Parameters
  • key (string) – The identifier for the collection member.

  • default (Undefined) – Optional argument for the value to return if key is not found.

items()

Return the identifiers of collection members (matching Python’s dict.items() functionality).

Returns

(key, value) pairs for each member of this collection.

Return type

list of tuples

keys()

Return the identifiers of collection members (matching Python’s dict.keys() functionality).

Returns

the identifiers for each member of this collection.

Return type

list of strings

values()

Return the values of collection (matching Python’s dict.values() functionality).

Returns

the members of this collection.

Return type

list