Blender 3.1 vertex crease values

How do I get the values of vertex crease using python?

Gave different crease values to the vertices and edges of the default cube.
I can get the crease value of the edges by

for e in bpy.data.meshes[‘Cube’].edges:
print(e.crease)

I cannot find a similar method for vertices.

1 Like

found it:
obj = bpy.context.active_object

crease_data = obj.data.vertex_creases[0]

for i in range(len(obj.data.vertices)):
    crease_data.data[i].value # get crease data

you can write to it too.

1 Like

Fantastic! Thank you very much.

@brecht I’m not sure if this is bug - that we cant access new vert.crease in bmesh, but we can for edges.crease? Should I report this?
https://docs.blender.org/api/current/bmesh.types.html#custom-data-layer-access

@KevinDietrich added the vertex creases.

Access to BMesh layers is apparently hard coded, I can quickly make a patch for it.

@KevinDietrich Please do. Also I found that there is no new() method in:
C.active_object.data.vertex_creases.new()
thus we cant set vert creases, like its shown in second post, - blender will error with :
image

Compare to vertex_colors where where have new() method:
C.active_object.data.vertex_colors.new()

But with bmesh custom crease data layer, I guess it wont matter (we will be able to create crease with bm.verts.layers.crease.new() right? )

The BMesh access was just committed, which does allow to create a new layer.

Creating a layer through mesh.vertex_creases is not possible yet, I can also make a patch for that.

1 Like

Awesome will test is ASAP. It would be great if, for consistency with vert color, you could add mesh.vert_crease. mesh.vert_creases has foreach_set, and get methods which may be usefull for fast crease access.