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