0
$\begingroup$

I am newbie in geonodes and, after some googling, I still do not know how to find answer to my question.

My data: Mesh, made of vertices only. Each vertex is assigned to Vertex Group, therefore vertices of the mesh can be divided to separate subsets. (Example on pictures: I have mesh made of vertices, vertex_group_1 includes upper circle of vertices, vertex_group_2 includes lower circle of vertices)

My goal: to make curve from vertices from the same Vertex Group for each(!) Vertex Group and, as a result, to have a set of curves. If there were n Vertex Groups, I expect n curves as a result. (Example on pictures: as a result I want to have two circle-shaped curves, upper and lower, not a spiral!)

Expected solution: GeoNode "Points to Curves" is supposed to make what I want, as the documentation says "All points with the same Group ID value will be joined in the same curve".

Question: How can I convert my Vertex Group information from mesh to Group Id for PointCloud? I can convert my mesh to point cloud with "Mesh to Points", what is next?

Another expected solution: My mesh is the result of my own script, so I can also make a Point Cloud from it in my script too (I hope it is easy). BUT how should I add "Group Id" to it? Should it be a custom attribute with "group id" name? And how the "Points to Curves" geonode will derive this information, will it derive it automatically when I plug my point cloud geometry to "point" attribute?

Obviously, I do not understand something basic about geonodes.enter image description here

$\endgroup$

2 Answers 2

1
$\begingroup$

(Using Blender 3.6.1) Vertex Group to ID From the above picture, it seems that every Vertex Group is a different Attribute. For a vertex belonging to a Vertex Group, the value is the Weight set in Edit Mode; for the vertices not belonging to the Vertex Group, the value is zero. So the name of every Vertex Group is required a priori to make a selection, that can feed a Set ID node. Working with version 3.6.1, I can not check if it is a valid input for the Points to Curves node you are using. However, getting inspiration from the post What is the Group Id input in the "Index of Nearest" node?, I succeeded to make it work with an Index of Nearest node.

$\endgroup$
4
  • $\begingroup$ StefLAncien, thank you for your answer! As I understand, you suggest to manually define the name of particular vertex group with "Named attribute node" and make curve from this particular group. Is this what you mean? Thus we can do that for each vertex group, if we know their names and count. But my goal is to make curves for each vertex group in any mesh, and in meshes the number of their vertex groups and names are various. Is there way to somehow connect information about ALL vertex groups and Group Id input? If no, is there another concept to solve such cases? $\endgroup$
    – Mariya
    Commented Dec 5, 2023 at 0:32
  • $\begingroup$ You're welcome. Could you have a naming convention for the Vertex Group name, such as "MyVertexGroup_n" where the trailing "n" will be the Group ID ? By the way, how do you assign vertices to Vertex Groups ? Selecting them in Edit Mode ? $\endgroup$ Commented Dec 5, 2023 at 5:18
  • $\begingroup$ Yes, there is such convention for names. I assign vertices to VG in my script (it works correctly, after running script groups are visible in panel with vertex groups of the object and all vertices of particular group can be selected with button "select") $\endgroup$
    – Mariya
    Commented Dec 5, 2023 at 13:41
  • $\begingroup$ I advise to assign the GroupID at the same time as the Vertex Group in your script. I post in another answer a piece of code showing how to do that. $\endgroup$ Commented Dec 8, 2023 at 22:36
1
$\begingroup$

(Using Blender 3.6.1 and python)

Here is a piece of code to create the 'id' attribute and to set its value per vertex :

import bpy
import numpy

active_obj = bpy.context.active_object

# Split vertices in two groups (for demo)
count = len(active_obj.data.vertices)
GroupID = numpy.repeat([1,2],count/2)

# Create the attribute
active_obj.data.attributes.new(name='id', type='INT', domain='POINT')

# Set the attribute value
active_obj.data.attributes['id'].data.foreach_set('value', GroupID)

Reference : I took information from Python : Custom Attribute for Vertices and Manually setting custom attributes per edge / vertex / etc.

$\endgroup$

You must log in to answer this question.

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