Hello, I want to get the freestyle property of the currently selected edge in editing, but Object.data cannot be updated in real time in grid editing mode, I tried using Object.data.update (), but this didn’t work, I want to know how to update it in real time. Or is there an API for freestyle in BMesh? I saw there was a post before, but no one replied, it was this one Access freestyle edges through bmesh - Other Development Topics / Python API - Blender Developer Talk
In the linked thread (two years ago), I ended up copying the BMesh data to a temporary Mesh object, and reading the properties from there. It is an ugly workaround but it still works:
def get_freestyle_marks(bm):
# NOTE: this is a workaround for NotImplementedError on bmesh.edges.layers.freestyle
mesh = bpy.data.meshes.new("temp")
bm.to_mesh(mesh)
result = {bmedge: mesh.edges[bmedge.index].use_freestyle_mark for bmedge in bm.edges}
bpy.data.meshes.remove(mesh)
return result