4

I'm editing a mesh using a script, while in Edit Mode. I need to display the Edge Angles while editing, but these don't get updated until I leave and re-enter Edit Mode.

Is there a function I can call to force updating the displayed Edge Angles while staying in Edit Mode?

Minimal example (slightly edited from "Bmesh Simple Editmode":

# This example assumes we have a mesh object in edit-mode

import bpy
import bmesh

# Get the active mesh
obj = bpy.context.edit_object
me = obj.data


# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)

bm.faces.active = None

# Modify the BMesh, can do anything here...
bm.verts[0].co.x -= 1.0


# Show the updates in the viewport
# and recalculate n-gon tessellation.
bmesh.update_edit_mesh(me, True)

Jake
  • 93
  • 6

2 Answers2

5

Need to update the normals.

Thanks to the information in the invalid bug report the angle info needed requires the face normals. This can be achieved by calling Bmesh.normal_update()

# This example assumes we have a mesh object in edit-mode

import bpy
import bmesh

# Get the active mesh
obj = bpy.context.edit_object
me = obj.data

# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)

bm.faces.active = None

# Modify the BMesh, can do anything here...
bm.verts[0].co.x -= 1.0

# recalculate normals.
bm.normal_update()
bmesh.update_edit_mesh(me, True) 

or by calling BMFace.normal_update() for each affected face. Simple example on all faces.

# recalculate normals.
for f in bm.faces:
    f.normal_update()

PS. not the normal avenue to come to a solution, and apologies for suggesting the dud bug report. (Another Doh moment on reading bug report lol)

batFINGER
  • 84,216
  • 10
  • 108
  • 233
4

I'm trying to guess why you need to stay in edit mode. If it isn't critical you can add,

bpy.ops.object.editmode_toggle()
bpy.ops.object.editmode_toggle()

(both lines) before the call to update. This is essentially doing in code what you do manually in the gif - flipping from object back to edit mode to update the display of length values.

Updating the 3d view is also covered in this answer here

enter image description here

d8sconz
  • 603
  • 4
  • 11