How to change point cloud data using python?

Hi,

I have several questions:
1/ How can we define an exact number of point using point cloud ?

2/ How can we access data from point cloud using python, to change each point location ?

3/ How to drive material using point data ?

Thank you !

Maybe my question is not that clear and I should simplify it to the most important for me now,

How can I assign to each individual point from the “distribute points on faces” a position according to a file I read in python (a csv with x and y position)

import bpy
import random

mesh = bpy.data.meshes["Cube"]
# your data should be under the form (x1, y1, z1, x2, y2, z2, ... , xn, yn, zn)
# Here I'll initialize a random array of 3 * verts (3 floats per vert for its coordinates)
verts = len(mesh.vertices)
locations = [random.random() for i in range(3 * verts)]
mesh.vertices.foreach_set("co", locations)
mesh.update()

For the attribute :

attr = mesh.attributes.new(name="material", type="FLOAT", domain="POINT")
attrs = [random.random() for i in range(verts)]
attr.data.foreach_set("value", attrs)

Result :
image
GN tree :


Shader tree :

Viewport (Cycles only) :
image

See https://docs.blender.org/api/current/bpy.types.FloatAttributeValue.html#bpy.types.FloatAttributeValue

1 Like