I'm building a custom menu using Serpens and python and I'm trying to recreate the same behavior than the menu we can find in the Item tab:
In order to do that I have this little code I'm using in Serpens
o = bpy.context.object
d = o.data
bm = bmesh.from_edit_mesh( d )
creaseLayer = bm.edges.layers.crease.verify()
selectedEdges = [ e for e in bm.edges if e.select ]
for e in selectedEdges: e[ creaseLayer ] = crease_weight
bmesh.update_edit_mesh( d )
This was made by looking at this previous post regarding a similar query from the past: Python code for Edge Data Bevel and Crease Weight?
However since Blender 4.0 it seems like the way to edit Creases changed and this code doesn't work anymore. What would be the best way to re-create this behavior now.
I've looked into bpy.ops.transform.edge_crease(value=newCreaseValue) and edge_creases_ensure but I'm not sure how to properly use them in my case.
Apologies for my lack and knowledge and thank you in advance!
Solution found: We have to use this line to get the Crease layer, as Crease as been moved to a named float attribute:
creaseLayer = bm.edges.layers.float.get('crease_edge', None) if bpy.app.version >= (4,0,0) else bm.edges.layers.crease.active