I created a series of objects that spawn individually over a time line. Something like a drop ship where one ship comes out at a time.
After all the objects are in their position, I want the to merge all at the same time back to one position.
So on the outer loop, I want it to take those objects and then change their final position and add a key frame to each one of them.
Is there a simple way to iterate over the objects created in the nested for loop or do I have to create a list, then iterate over that list on the first for loop? I know this may be more of a coding question but was wondering if the the blender library could call all objects just created.
import bpy
import time
from random import randint
number = 10
for i in range(0,number):
for i in range (0,number): ##Create Batch of 10 Objects
bpy.ops.mesh.primitive_uv_sphere_add(location=(0,0,0)) ##Create UV Sphere
bpy.ops.anim.keyframe_insert_menu(type='Location') ##Add Keyframe for recently created Sphere
x=randint(-10,10)
y=randint(-2,2)
z=randint(-10,-1)
bpy.context.scene.frame_set(bpy.context.scene.frame_current + randint(1,10)) #Move Frame to a random Location
bpy.ops.transform.translate(value=(x,y,z)) #Move Object to new location
bpy.ops.anim.keyframe_insert_menu(type='Location') #Add Keyframe for new Location
x=randint(-10,10)
y=randint(-10,10)
y=randint(-2,2)
z=randint(-10,10)
bpy.context.scene.frame_set(bpy.context.scene.frame_current + randint(1,10))
bpy.context.object.location = (x, y, z)
bpy.ops.anim.keyframe_insert_menu(type='Location')
#Now I want the objects that were created in the for loop, to all move together to one point at the same time.
bpy.context.scene.frame_set(bpy.context.scene.frame_current + 5)
bpy.context.object.location = (0, 0, 0)
bpy.ops.anim.keyframe_insert_menu(type='Location')