0
$\begingroup$

To reproduce the problem and make the script runnable, make sure:

  • Add a Ico Sphere to scene and
  • Enter edit mode and select the top vertex

1

2


# It moves the selected vertices down a bit
import bpy, bmesh

ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)

act_vert = next(v for v in bm.verts if v.select)
act_vert.co.z -= 0.2

me.update(calc_edges=True, calc_edges_loose=True)
me.update_gpu_tag()
bmesh.update_edit_mesh(me)

After running the code, it looks like:

3

When press the Tab key twice (Go to object mode and switch back), the shading are completely different

4


I know I can run the operator bpy.ops.object.mode_set twice to update the mesh, but I want to know how to update it without exiting edit mode

$\endgroup$

1 Answer 1

0
$\begingroup$

Using bmesh.update_edit_mesh before the update_edit_mesh

bm.normal_update()
bmesh.update_edit_mesh(me)

or

bm.normal_update()
me.update()

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.