4
$\begingroup$

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)

$\endgroup$
5
  • $\begingroup$ 2.78.5 2.79 - in this versions I haven't this problem. Maybe you need to update Blender? $\endgroup$
    – Crantisz
    Jan 22, 2018 at 14:58
  • $\begingroup$ @batFINGER have you tried official blender build from blender.org? $\endgroup$
    – Crantisz
    Jan 23, 2018 at 9:53
  • 1
    $\begingroup$ @batFinger: Thanks for the info. I'm currently using an official Blender 2.78c build on Linux 64bit. I'll give the official 2.79 version a shot tonight, and file a bug report if the behaviour is still there. $\endgroup$
    – Jake
    Jan 23, 2018 at 10:19
  • $\begingroup$ @batFINGER for bug report you need to know what versions has this. Now I have no idea about that. $\endgroup$
    – Crantisz
    Jan 23, 2018 at 11:06
  • $\begingroup$ I've opened a bug report $\endgroup$
    – Jake
    Jan 23, 2018 at 22:55

2 Answers 2

5
+50
$\begingroup$

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)

$\endgroup$
4
$\begingroup$

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .