I am trying to copy Cube and set different random origins to the copies. I use the following code:
import bpy import random C = bpy.context src_obj = bpy.data.objects['Cube'] for i in range (0,5): new_obj = src_obj.copy() new_obj.data = src_obj.data.copy() new_obj.animation_data_clear() C.collection.objects.link(new_obj) new_origin = (0.0+random.randint(1, 9)/100,0.0+random.randint(1, 9)/100,0.0+random.randint(1, 9)/100) print(new_origin) C.scene.cursor.location = new_origin new_obj.select_set(True) bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
The objects are successfully copied, but their origins are always the same: they are equal to last generated coordinates. I added print to make sure that new_origin is always different, but the last value of new_origin is applied. What I am doing wrong? How to make the origins to be different?