bpy data access between modes

Hello,
I’m a long time reader, first time poster.
How does one access and/or change the properties of objects or the meshes they contain that are not in the current edit mode?
Specifically, I’d like to be able to enter edit mode for object 1, change the position of a vertex and use python to read or affect the position of object 2 or the mesh it contains while remaining in edit mode of object 1.
Thanks in advance.

So far, I can move a vertex in edit mode of object 1 while my python script calculates the resulting position change of object 2. However, the position change of object 2 is not visible while remaining in edit mode for object 1. The position of object 2 does change in the 3D view when switching back to object mode, but for the sake of the project I am building I’ll need to see the change while remaining in edit mode.
Thanks again!

You don’t really need to put the mesh in edit mode to change or alter it. You can fetch the vertices directly and make the changes. Managing modes complicates your code and has it’s own limitations. But if your script is intended to be a modeling tool then that might be the way to go. If your script is intended to be an animation tool then direct manipulation is the way to proceed.


import bpy


ob = bpy.data.objects.get("Cube")
me = ob.data
v = me.vertices[0]
# NOTE: co stands for coordinate 0=x, 1=y, 2=z.
v.co[0] = v.co[0] + 1

Thanks, Atom.
You’re right about this being a modelling tool. I’ll be selecting a vertex with the mouse and dragging it to see the resulting change in the other object. It would simplify my process to be able to select and move a vertex without entering edit mode. Any suggestions? THANKS AGAIN!