Mesh Data: Not Updating in Edit Mode

Hi, I’ve been working on a script where the following function may be run in or out of edit mode, but I’m finding that when I change the mesh geometry in edit mode the list returned by this function does not update unless I toggle into object mode first.

def findVerts(ob):
    "Return a list of xyz coordinates for each vertex"
    list = []
    for v in
    return list

Does anyone know a way to fix this, besides having the script toggle in and out of object mode automatically? Thanks.

P.S. I’m using Blender2.58 on Windows 64 bit.

To my knowledge you are forced to use going out and in edit-mode … ;-(
I came across this too … (2.58 and W32)

Right now to fix the problem I now have the following 2 lines:


The problems here is if you’re in object mode it’s unnecessary and if for some reason your in a mode other than edit or object mode you’ll end up in object mode… but at least it always works (I think).

Is there a way to get the current mode? (Sorry dumb question but can’t find it)

1 Like

Yes, e.g.

or any (mesh) object, which can be edited

I prefer to use mode_set():


Thank you both for your help! – Dragonrider

I use them like this:

    if bpy.context.mode!='OBJECT':


    #   RE-SET MODE
    if bpy.context.mode!=m:

1 Like

Right now I just did the following.

currentMode = bpy.context.object.mode
bpy.ops.object.mode_set() #default is mode='OBJECT'

I might be wrong, but it seemed more efficient just to always switch to object mode then to use two if statements (let me know if I’m wrong). Actually I don’t know why I’m worrying about efficiency at all.

Also, in this case the mesh data doesn’t need to be retrieved in object mode. It does needs to be updated by going to object mode apparently. (I would like to just have an update command, which is why I started the thread).

With and if statement (maybe):

if bpy.context.mode!='OBJECT':

I was looking at this earlier, but no joy, because what I was trying I needed to be in Object mode anyway…

Maybe your test might get better use out of it… bpy.context.scene.update()

Unfortunately, bpy.context.scene.update() doesn’t seem to be working as a substitute, but thanks for the suggestion.

I was wondering the same thing, and asked on Blender Stack Exchange.

The solution appears to be to call item.update_from_editmode (), for example:

if bpy.context.mode=='EDIT_MESH':
    item.update_from_editmode ()

… where “item” is the object in question.