BlenderObjectAttribute
BlenderObjectAttribute(obj= None )
Minimal base class for Blender objects with attribute access.
This class provides core functionality for storing and accessing named attributes on Blender objects.
It is intended for use with Mesh, PointCloud and Curves type objects for easier and “numpy-like” attribute access.
It can be inherited by other classes for easier attribute management on objects.
Attributes
position
AttributeArray
Position attribute of the object’s vertices/points.
data
bpy.types .Mesh | bpy.types .Curves | bpy.types .PointCloud
The data block associated with this object.
attributes
The attributes collection of the object’s data-block.
Methods
evaluate
BlenderObjectAttribute.evaluate()
Return the evaluated version of the object, with all modifiers applied.
Returns
Object
The evaluated object from the dependency graph, which isn’t stored in bpy.data.objects.
list_attributes
BlenderObjectAttribute.list_attributes(evaluate= False , drop_hidden= False )
List the names of the object’s attributes.
Parameters
evaluate
bool
Whether to first evaluate the modifiers on the object before listing the available attributes. Defaults to False.
False
drop_hidden
bool
Whether to drop hidden attributes (those starting with a dot). Defaults to False.
False
named_attribute
BlenderObjectAttribute.named_attribute(name, evaluate= False )
Read a named attribute from the object as a numpy array.
Parameters
name
str
Name of the attribute to get.
required
evaluate
bool
Whether to evaluate the object’s modifiers before reading the attribute. Defaults to False.
False
Returns
np .ndarray
A copy of the attribute’s values, which doesn’t sync back to Blender.
remove_named_attribute
BlenderObjectAttribute.remove_named_attribute(name)
Remove a named attribute from the object.
Parameters
name
str
The name of the attribute to remove.
required
store_named_attribute
BlenderObjectAttribute.store_named_attribute(
data,
name,
atype= None ,
domain= None ,
)
Store a named attribute on the Blender object.
Parameters
data
np .ndarray
The data to be stored as an attribute.
required
name
str
The name for the attribute. An existing attribute with this name is overwritten, keeping its type and domain.
required
atype
str or AttributeTypes or None
The attribute type to store the data as. Either string or selection from the AttributeTypes enum. None uses the type of an existing attribute, otherwise infers the attribute type from the input array.
None
domain
str or AttributeDomains or None
The domain to store the attribute on. None uses the domain of an existing attribute, otherwise AttributeDomains.POINT.
None
Raises
TypeError
If the object’s data is not a Mesh, Curves or PointCloud.
ValueError
If atype or domain isn’t a valid name, no type can be inferred, or atype is FLOAT4 before Blender 5.2.
NamedAttributeError
If the data length doesn’t match the domain size, or atype or domain conflict with an existing attribute.
AttributeMismatchError
If the values can’t be represented by the attribute’s type.