1
$\begingroup$

I have a scene where I need to put in millions of particles. I want to represent each particle with a primitive, for example, a meta-ball object. All the particles can share the same primitive. The locations of the particles are from somewhere else, therefore I need to import them and create the particles inside blender with python scripts.

Currently, I'm testing the following scripts:

 for i in range(0, 100):
    for j in range(0, 100):
        bpy.ops.object.metaball_add(type='BALL', radius=0.1, enter_editmode=False, align='WORLD', location=(i*0.1, j*0.1, 0), scale=(1, 1, 1))

I input the code via the console, but this seems inefficient and freezes blender. Is there a way to create many copies of the same object more efficiently?

I also found the array modifier. The array modifier seems to be able to handle a very large number of objects without a problem. However, I'm not sure how to input arbitrary displacements for each individual copy. As in my case, each particle has its own displacement.

$\endgroup$
2
  • $\begingroup$ Suggestion. Measure,with Python tools, the time it takes to add a simple cube versus the time it takes to add metaballs. Metaballs are not the least expensive computer time primitive. I am not sure if you are including render time. Cleary a double for loop in Python wont be as fast as some other high performance programming language. $\endgroup$ Commented Dec 9, 2020 at 4:52
  • $\begingroup$ bpy.ops is not the more efficient. There is other apis. But what do you want to do once created (animated, static, ...)? Any particular reason to use metaball? $\endgroup$
    – lemon
    Commented Dec 9, 2020 at 6:56

1 Answer 1

2
$\begingroup$

I found a workaround, following this post: https://devtalk.blender.org/t/manipulating-particles-in-python/7552 I'm able to manipulate the positions of a particle system. So I created a particle system and then write in the positions. Then, I set the instance object of the particle system to be the primitive I want. I found a Nurbs sphere could work for me. In this way, I'm able to render 1 million particles with no problem.

1 Million metallic balls

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .