Creating 100 000+ objects


I would like to create 100 000+ spheres, make them move independently and change color based on a custom property common to all objects but with different value for each one.

However creating meshes takes a lot of time (blender crash if I ask more than 20 000). I wonder if there is a more efficient way, like particle system, to do it ?

The issue is that each object have different value in the custom data

Thank you

You can make a particle system with 100k particles, and apply it, which will make all the particles real objects. Two steps to 100K objects :slight_smile:

I foresee your difficulties with crashing extending beyond just “creating” those 100k objects, though. Working with them is going to be super laggy, and there’s a good chance Blender will crash as soon as you turn the particles up to 100k, and you run out of RAM.

Also… how do you plan to use one custom property to define 100K different colors? Because all of Blender’s color options are 0.0 to 1.0, you’re going to run into floating point precision errors. There’s no way to get 0-100000 into 0.0-1.0 without floating point precision errors.

I don’t mean to sound overly discouraging, I’m just wondering if there’s a better way to do whatever you’re looking to do. What is your end goal? Maybe there’s a trick or a visual hack that can get the same result, without the complexity :slight_smile:

1 Like

Thanks a lot for your answer !

I have 128 GO of RAM so I hope it’s gonna be OK, I hope that by running the script and rendering in headless mode without GUI it’s may work ?

I don’t need 100 000+ different colors, but scaled value from 0 to 1 from grey to bright red for example. Each object has a different value from 0-1 in a custom property

How can I make particles separate objects in python ?

You might want to explore Geometry Nodes, you can create point clouds with point-specific data inside. This will be hundreds or thousands of times more efficient than creating hundreds of thousands of different mesh objects

1 Like

Thank you for your answer, I found how to create a point cloud but i don’t see how to change each point location based on my data
Any idea ?

You can create a point cloud as a mesh

import bpy
mesh ='newmesh')

import random
rnd = lambda: 10-(random.random()*20)
vertices = [(rnd(),rnd(),rnd()) for i in range(100000)]
mesh.from_pydata(vertices=vertices, edges=[], faces=[])

ob ='newobject', mesh)

To attach more properties to each vertex you will need to use the custom attributes, or vertex colors. I have not looked about this particular piece currently, you will have to find it.

Then you can try to take this point cloud and use Geometry Nodes to generate spheres and other stuff.

1 Like