1

I have a problem, I use a mesh of about 230,000 vertices and 500,000 faces, it contains vertex groups, suppose you have to query a vertex group database and this returns some of them that you want to select on blender, my function it is good when I have to select 2-3 vertex_group but in a bad case where I have to select them all then my works take a long time to run. To give you an idea, the largest vertex group contains 40,000 vertices. What could I do?

def select_vertex(obj, vertex_group):
    bpy.context.view_layer.objects.active = obj 
    bpy.ops.object.mode_set(mode="OBJECT")
vertices = obj.data.vertices

for vertex in vertices:
    for vgroup in vertex.groups:
        if(vgroup.group==vertex_group):
            vertices[vertex.index].select = True

Imagine that this function is inside a loop that iterates through all the tuples that my query returned so "obj" will be my mesh while "vertex_group" the index of the vertex_group that i want to select

luke_mcp
  • 41
  • 3
  • Are you aware that Blender has a standalone function to select all vertices assigned to a vertex group: https://docs.blender.org/manual/en/latest/modeling/meshes/properties/vertex_groups/vertex_groups.html#editing-vertex-groups – RPaladin Aug 10 '22 at 21:00
  • fastest way is https://blender.stackexchange.com/questions/75223/finding-vertices-in-a-vertex-group-using-blenders-python-api . if it's still slow then there is nothing else you can do. – Harry McKenzie Aug 11 '22 at 05:47

0 Answers0