So I have this code that moves the vertices to the front on the affected objects:
import bpy, bmesh
#objects = bpy.context.selected_objects
objects = bpy.data.collections["Collection"].objects
for ob in objects:
bpy.ops.object.mode_set(mode='EDIT')
me = ob.data
bm = bmesh.from_edit_mesh(me)
verts = [v for v in bm.verts]
bmesh.ops.translate(bm, verts=verts, vec=(0.0, -20.0, 0.0))
bmesh.update_edit_mesh(me)
bpy.ops.object.mode_set(mode='OBJECT')
It works perfectly fine for 'selected objects' if it uses the second line instead of the third one. Similarly, the third line is directly copy-pasted from another code that works perfectly fine with the objects in "Collection".
But for whatever reason it just refuses to work here. It says that the objects must be in Edit mode
Oddly enough, if the objects are selected, even with the second line of code, it does work.
Any ideas why it's been stubborn?