I think everything is in the title : I want to deform my metaball object during animation.

Let's explain a bit more : I have several metaball objects in my scene, each of them composed of several metaball elements.

mball = bpy.data.metaballs.new("my_ball") 
obj = bpy.data.objects.new("my_object", mball)
elem1 = mball.elements.new(type="BALL")
elem1.co = Vector((0,0,0))
elem2 = mball.elements.new(type="BALL")
elem2.co = Vector((2,0,0))

(There are also stiffness, radius... that I didn't wrote for the sake of clarity)

This object can move/rotate with

obj.location = Vector((1,2,3))
obj.rotation = Quaternion((1,2,3,4))

and be animated simply with

obj.keyframe_insert(data_path="location"/"rotation", frame = 1)

Also, it must be able to fusion with other objects, so those objects are named "my_object.001", "my_object.002", ...

Now, the problem is that I want to deform the object during the animation :

elem2.co = Vector((0,2,0))
obj.keyframe_insert(data_path="location", frame = 100) # Of course, it doesn't work

One solution would be to use only objects with one metaball element each, and use lists of metaball objects for my (semantic) objects. But it will be particularly difficult to handle rotations...

  • $\begingroup$ Well, I didn't find anything more so I'll just switch to using one metaball element per object, and working with object hierarchy... $\endgroup$ – Tawy Mar 4 '14 at 10:14

With obj.keyframe_insert you are adding a keyframe for the object, not the element.

To set keyframes for elem2 you want to use elem2.keyframe_insert

elem2.co = Vector((2,0,0))
elem2.keyframe_insert(data_path="co", frame = 10)

elem2.co = Vector((0,2,0))
elem2.keyframe_insert(data_path="co", frame = 100)
  • $\begingroup$ Thanks, I just understood the concept of "data_path" (I thought it was some sort of type, like in bpy.ops.anim.keyframe_insert()...) but it seems logical now. $\endgroup$ – Tawy Mar 5 '14 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.