# Import data (x,y,z + attributes) from file into geometry nodes

I have some data with cartesian coordinates + some attributes (e.g. size, rotation, and/or color) outside blender and want to use that as basis for geometry nodes. For example, I want to use the vertices as instances for cubes or spheres and use additional attributes to scale/rotate/etc the instances accordingly.

Is it currently possible to read in the data from a file (e.g. csv, ply, etc.) into geometry nodes maybe by using the import functions or by using the python API with a small script?

At the moment I save the data into a .ply-file with properties x, y, z, red, green, blue, so I have the points. However, using the red, green, and blue property seems useless without using faces and I end up with the vertices which I can instance, but not transform.

Maybe it would also be possible to import the data in two steps.

1. One x-y-z file with the actual vertices
2. Additional information given in another file with x-y-z information, but with the meaning of attr1, attr2, attr3.
• using this additonal geometry for the actual object (e.g. distance from the origin for size) and
• removing the geometry from the final result again (which I don't know at the moment how to do; probably something with join geometry first, then at the end with point separate and some condition evaluated before)
• This seems a bit complicated though.

The csv file can be read into blender with python. By using the blender API the data can then be assigned to an attribute which is accessible also in Geometry nodes.

From Python : Custom Attribute for Vertices I got the piece of code how to set an attribute. However, I haven't managed to only set a float array, instead of a float-vector array. Therefore in Geometry nodes the float-vector has to be separated by x,y,z and assigned to a scale attribute. This step is most probably unnecessary if the attribute is set correctly in python beforehand.

import bpy
import csv
import numpy

filepath = "blender_GN_test.csv" # 4 comma-separated columns without header
csvfile = open(filepath, 'r', newline='')
verts = []
s = []

for row in ofile:
verts.append(Vector((float(row[0]), float(row[1]), float(row[2]))))
s.append(float(row[3]))

csvfile.close()

obj_name = "MyObj"
mesh_data = bpy.data.meshes.new(obj_name + "_data")
obj = bpy.data.objects.new(obj_name, mesh_data)