databpy 0.13.0
  • Home
  • Guides
    • Attributes
    • Syncing with Blender
    • Grease pencil and evaluated geometry
  • API
  • Changelog
  1. Attribute
  2. named_attribute
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • list_attributes
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
    • Attribute
    • attribute.guess_atype_from_array
  • Typed arrays
    • float32
    • vec2
    • vec3
    • vec4
    • color
    • srgb
    • color8
    • quat
    • mat4
    • int32
    • int8
    • ivec2
    • sivec2
    • boolean
    • string
  • Collections
    • create_collection
    • move_to_collection
  • Objects
    • create_object
    • create_mesh_object
    • create_curves_object
    • create_grease_pencil_object
    • create_pointcloud_object
    • create_bob
    • evaluate_object
    • GeometrySet
    • BlenderObject
    • AttributeDomainView
    • InstanceDomainView
    • Drawing
    • Drawings
    • 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

  • Parameters
  • Returns
  • Raises
  • Examples
  1. Attribute
  2. named_attribute

named_attribute

named_attribute(obj, name='position', evaluate=False, *, atype=None)

Read the values of a named attribute into a numpy array.

Parameters

Name Type Description Default
obj bpy.types.Object The Blender object. required
name str The name of the attribute, by default ‘position’. 'position'
evaluate bool Whether to evaluate modifiers before reading, by default False. False
atype type[AttributeArray] or None The typed array class the attribute is expected to be, such as vec3. The values are returned as that class, which type checkers also see. None

Returns

Name Type Description
np.ndarray The attribute data as a numpy array, or an array of atype if given.

Raises

Name Type Description
AttributeNotFoundError If the named attribute does not exist on the object.
NamedAttributeError If the attribute’s type doesn’t match atype.
TypeError If obj isn’t an object, or its data isn’t a mesh, curves, point cloud or grease pencil.

Examples

import bpy
from databpy import named_attribute, list_attributes
obj = bpy.data.objects["Cube"]
print(f"{list_attributes(obj)=}")
list_attributes(obj)=['.corner_edge', '.corner_vert', '.edge_verts', '.select_edge', '.select_poly', '.select_vert', '.uv_select_edge', '.uv_select_face', '.uv_select_vert', 'UVMap', 'position', 'sharp_face']
named_attribute(obj, "position")
array([[ 1.,  1.,  1.],
       [ 1.,  1., -1.],
       [ 1., -1.,  1.],
       [ 1., -1., -1.],
       [-1.,  1.,  1.],
       [-1.,  1., -1.],
       [-1., -1.,  1.],
       [-1., -1., -1.]], dtype=float32)
Function reference
store_named_attribute