2
$\begingroup$

Is it possible to assign custom properties to vertices (or edges or faces)? If yes, how?

The manual says that custom properties are only supported for datablocks with an ID. what exactly is meant with this ID?

$\endgroup$
1
$\begingroup$

Only objects which are derived from bpy.types.ID support custom properties. These subclasses are listed here: API docs - bpy.types.ID. You access them via bpy.data.

Additionally, Bone and PoseBone objects support custom properties as well: API docs - bpy.props.

The standard API does not support custom data for geometry elements (bpy).
The BMesh Module (bmesh) does however.

Note that custom data layers are rather slow when utilized with Python.

Keep in mind the "propagation" of custom data, the attributes are copied on operations like extrusion - hence, you can't really use it to give each vert / edge / face a unique number for instance.

See also:

| improve this answer | |
$\endgroup$
  • $\begingroup$ I am new to the BMesh Module. If I understand this correctly Blender just stores the Mesh. A Bmesh is only created each time you switch to editmode or if you use it in Python. Then it gets thrown away again. Won't the custom data be gone too then? $\endgroup$ – horace Apr 29 '14 at 19:25
  • $\begingroup$ I also have a question about the .index property of vertices. It has nothing to do with an access like verts[index] right? What is its purpose then? The manual says it also can be used to store arbitrary ints. But why is it named index then? I find it a bit confusing. :) $\endgroup$ – horace Apr 29 '14 at 19:28
  • $\begingroup$ Since Blender 2.63, all Meshes are BMeshes (meshes that consist of triangles, quads and ngons). When you switch to edit mode, a different representation is used. But it's not directly related to the BMesh module, which is rather a wrapper for BMeshes. It allows for easy manipulation of a mesh compared to the standard API (you don't have to deal with loops for instance). The BMesh module can create BMesh objects in memory, without ever creating a mesh datablock, but also wrap an editmesh an change it without mode switching. $\endgroup$ – CodeManX Apr 29 '14 at 19:46
  • 1
    $\begingroup$ verts[index] is usually equal to .index, but scripts can overwrite the index property for internal purposes. It does not change the actual vertex index. You can test that with a wrapped bmesh - bm = bmesh.from_edit_mesh(bpy.context.object.data) - and indices displayed in viewport: bpy.app.debug = True and Indices enabled in N-panel, Mesh Display options. To reset the temporary overwritten indices, use bm.verts.index_update(). $\endgroup$ – CodeManX Apr 29 '14 at 19:52
  • $\begingroup$ They only get reset manually by bm.verts.index_update()? Otherwise they never get reset? So i could use them for custom data? $\endgroup$ – horace Apr 29 '14 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.