Hi everyone I am making an addon for my degree thesis, I have a problem with the following: I have to count the number of faces of each vertex group present in my scene and i use this function
for x in list(bpy.data.objects):
list_vertex = []
for vertex in vs:
for g in vertex.groups:
if (g.group == i):
list_vertex.append(vertex.index)
break
for face in list(bpy.data.objects[x.name].data.polygons):
isFace = False
count = 0
for vertex in face.vertices:
if vertex in list_vertex:
isFace = True
count+=1
else: isFace = False
if isFace == False:
break
if count == len(face.vertices):
count_face += 1
If I try to run the addon on a mesh with few vertices then everything works, if instead I use a bigger scene blender stops working immediately so I think my problem is related to the performance of my code, I'm new to addon programming, could anyone tell me if there is a more optimal method to do this?
vs
? What isi
? They're defined outside of the quoted code. $\endgroup$vertex in list_vertex
will be very slow. Also don't uselist()
on thedata.polygons
. $\endgroup$