I’m trying to write a small code snippet that loops through all of the objects in my scene and sets the origin to geometry for each one. However, it only seems to execute for the last object in the scene - everything else remains untouched. The only thing I can think of is maybe the for loop is moving on to the next object before the origin_set() function has time to finish. Has anyone else seen this issue before?
import bpy
for obj in bpy.data.objects:
bpy.context.scene.objects.active = obj
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
print("Setting origin: " + obj.name)