databpy 0.11.0
  • Home
  • Attributes
  • API
  • Changelog
  1. Objects
  2. BlenderObjectAttribute
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • list_attributes
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
    • Attribute
    • attribute.guess_atype_from_array
  • Collections
    • create_collection
    • move_to_collection
  • Objects
    • create_object
    • create_mesh_object
    • create_curves_object
    • create_pointcloud_object
    • create_bob
    • evaluate_object
    • GeometrySet
    • BlenderObject
    • BlenderObjectAttribute
    • BlenderObjectBase
  • Errors
    • DatabpyError
    • NamedAttributeError
    • AttributeNotFoundError
    • AttributeMismatchError
    • LinkedObjectError
  • Utilities
    • require
    • require_data
    • mesh_data
    • curves_data
    • pointcloud_data
    • volume_data
    • active_scene
    • active_object
    • centre
    • lerp
  • Nodes (deprecated)
    • nodes.new_tree
    • nodes.swap_tree
    • nodes.custom_string_iswitch
    • nodes.append_from_blend
    • nodes.new_socket
    • nodes.tree_interface
    • nodes.input_socket
    • nodes.output_socket
    • nodes.socket_value
    • nodes.set_socket_value
    • nodes.MaintainConnections
    • nodes.DuplicatePrevention

On this page

  • BlenderObjectAttribute
    • Attributes
    • Methods
  1. Objects
  2. BlenderObjectAttribute

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

Name Type Description
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

Name Description
evaluate Return the evaluated version of the object, with all modifiers applied.
list_attributes List the names of the object’s attributes.
named_attribute Read a named attribute from the object as a numpy array.
remove_named_attribute Remove a named attribute from the object.
store_named_attribute Store a named attribute on the Blender object.

evaluate

BlenderObjectAttribute.evaluate()

Return the evaluated version of the object, with all modifiers applied.

Returns

Name Type Description
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

Name Type Description Default
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

Returns

Name Type Description
list[str] The attribute names.

named_attribute

BlenderObjectAttribute.named_attribute(name, evaluate=False)

Read a named attribute from the object as a numpy array.

Parameters

Name Type Description Default
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

Name Type Description
np.ndarray A copy of the attribute’s values, which doesn’t sync back to Blender.

Raises

Name Type Description
AttributeNotFoundError If the attribute doesn’t exist.

remove_named_attribute

BlenderObjectAttribute.remove_named_attribute(name)

Remove a named attribute from the object.

Parameters

Name Type Description Default
name str The name of the attribute to remove. required

Raises

Name Type Description
AttributeNotFoundError If the attribute doesn’t exist.
NamedAttributeError If the attribute is required by Blender (e.g. position) and can’t be removed.

store_named_attribute

BlenderObjectAttribute.store_named_attribute(
    data,
    name,
    atype=None,
    domain=None,
)

Store a named attribute on the Blender object.

Parameters

Name Type Description Default
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

Returns

Name Type Description
bpy.types.Attribute The added or modified attribute.

Raises

Name Type Description
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.
BlenderObject
BlenderObjectBase