As far as I understand, in Geometry Nodes in Blender 2.9* it is possible to add custom attributes to vertices (to have not just the
XYZ position, but say
density_tree). For instance, this video (14mn) shows how Attribute Vector can be used to create a new attribute, visualized in the spreadsheet as a new column. However, in Blender 3.0 this node does not exist anymore. What is the 3.0 way of creating/reading custom attributes in Geometry Nodes?
For instance, I may like to use it to interface my nodes with an external python script: the python script would add custom attributes to each point depending on some potentially complex procedures, and the Geometry node could then read these attributes and proceed accordingly.
The proposed answer does not solve my problem, I'm looking for a way to set/get a per vertex attribute (I think it is called sometimes layer in the python API).
For instance, let's say that I have a cube selected in edit mode. Then I can do:
import bmesh mesh = bpy.context.view_layer.objects.active.data bm = bmesh.from_edit_mesh(mesh) layer_kind = bm.verts.layers.int.new("mykind") bm.verts[layer_kind] = 42
and it will create a new column
mykind, with the first vertex having the value
42 and the others
Now, could I get/set this custom per-vertex attribute, using Geometry Nodes in Blender 3.0? For instance, to draw a cylinder at the vertex position when the kind is 42 and a cube otherwise?
Thanks to Chris and Blunder, I can now do more or less what I want... Here is basically the picture given by Blunder where I added the important parts in red:
However, the user of the modifier needs to configure the name of the attribute (rightmost part) while I would prefer to have it hardcoded into my Geometry Node. Do you know if it's possible?
I also tried to create a new attribute instead, and it works similarly (in fact, no need to use python to create a new attribute, I can just write any name and it will be created automatically. But again, it would be cool to hardcode the name in the node directly (or at least provide a default name for the attribute).