0
$\begingroup$

In the example related to metaballs, [Creative Coding Primer] https://blenderscripting.blogspot.com/2012/09/tripping-metaballs-python.html, a sphere is linked to a metaball.

I am wondering what is the relationship of the sphere to the metaball?

For context, I am trying this script to animate a metaball that updates each of its elements' coordinates. The metaball elements update perfectly, but their meshes never move.

I am wondering if this has anything to do with the linking line that I don't understand, of it here is a metaball update function I have not come across.

import bpy
import random

scene = bpy.context.scene

# add metaball object
mball = bpy.data.metaballs.new("MetaBall")
obj = bpy.data.objects.new("MetaBallObject", mball)
scene.objects.link(obj)

mball.resolution = 0.2   # View resolution
mball.render_resolution = 0.02


for i in range(20):
    coordinate = tuple(random.uniform(-4,4) for i in range(3))

    element = mball.elements.new()
    element.co = coordinate
    element.radius = 2.0

 for i in range(10):
     element = mball.elements[i]
     new_coordinate = tuple(random.uniform(-4,4) for i in range(3))
     element.co = new_coordinate
     element.keyframe_insert(data_path="co", frame=300)
```
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.