Get edit mode edge freestyle data


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

你好,我想在编辑获取当前所选边的freestyle属性,但是object.data无法在网格编辑模式实时更新,我尝试过使用object.data.update(),但这个没有用,我想知道怎么才能实时更新,或者在bmesh里面有freestyle的api吗,我看到了以前有一个帖子,但是没有人回复,是这一个

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
1 Like

Thank you, this is available, I did not expect to solve this, this is the official API has not been fixed, or there is no this function

谢谢,这个是可用的,没想到需要这样来解决,这个是官方的api没有修复吗,还是没有这个功能啊