index n out of range

Hi,

I’m tryng to make a script that look inside a mesh with several parts, and delete the smallest (< thresold)

I’d like using bmesh to stay only one time in EDIT mode, and the first try I wrote works if the thresold only bigger than the smallest part; if I increase the thresold over the second smallest part, the script fail and give me the error “index n out range” (where n is the index of the face)

For better explain try to run Text script in . blend attached using the value FaceThresold = 0, 10 and 20; when using 20 it start to fail.
DeleteIsolatedParts.blend (182 KB)

Someone can help me understanding what I’m doing wrong?

Thanks!! :slight_smile:

If you delete some verts in first past
it will re index all others so first index list won’t be good anyway!

hope it helps

happy bl

Yeah!! I understand!! Thank you!! :smiley: (now it works)