databpy
  • Home
  • API
  1. Attribute
  2. named_attribute
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
  • Collections
    • create_collection
  • Objects
    • create_object
    • create_bob
    • evaluate_object
    • BlenderObject
    • LinkedObjectError

On this page

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

named_attribute

named_attribute(obj, name='position', evaluate=False)

Get the named attribute data from the object.

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

Returns

Name Type Description
np.ndarray The attribute data as a numpy array.

Raises

Name Type Description
AttributeError If the named attribute does not exist on the mesh.

Examples

import bpy
from databpy import named_attribute, list_attributes
obj = bpy.data.objects["Cube"]
print(f"{list_attributes(obj)=}")
named_attribute(obj, "position")
list_attributes(obj)=['position', '.select_vert', '.edge_verts', '.select_edge', '.select_poly', 'sharp_face', '.corner_vert', '.corner_edge', 'UVMap']
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.]])