Inspired by a post on BA, it just so happens that i can use this for my own particle script. It's pretty basic but easy enough to elaborate on.
While this first solution will work, it is not optimal on massive datasets because it uses
(using bpy.ops like in the following snippet is not recommended)
Here is a version that uses the data_path and avoids using( recommended )
While this first solution will work, it is not optimal on massive datasets because it uses
bpy.ops
inside the positions loop. The short story about bpy.ops is that ops operations are really meant to be called from the UI directly, where you won't notice the slowdown (blender state refreshes) between clicks.(using bpy.ops like in the following snippet is not recommended)
import bpy start_pos = (0,0,0) bpy.ops.mesh.primitive_uv_sphere_add(segments=32, size=0.3, location=start_pos) bpy.ops.object.shade_smooth() positions = (0,0,2),(0,1,2),(3,2,1),(3,4,1),(1,2,1) frame_num = 0 for position in positions: bpy.context.scene.frame_set(frame_num) bpy.context.active_object.location = position bpy.ops.anim.keyframe_insert(type='Location', confirm_success=True) frame_num += 10
Here is a version that uses the data_path and avoids using
bpy.ops
in the loop