As the title says, I am using bmesh.verts to load in all the vertices of a mesh to then check if their coordinates are within a certain box, and if they are select them. The problem is that the function seemingly doesn't load in all of the vertices of the mesh, but only roughly a couple tens of thousands when I have over a million vertices in the mesh. I figured this out by counting the amount of vertices where loaded in by the function at hand.
Is this a problem that can be solved somehow? Is this dependent on the amount of RAM used or some other memory related issue?
Important notice: This works perfectly fine if you copy and paste each command into the python console, but does not work when the script is run by itself.
This is the syntax:
def SelectVerticesInBound(object, vector1, vector2): # get the mesh data from the object reference mesh = object.data # get the bmesh data if mesh.is_editmode: bm = bmesh.from_edit_mesh(mesh) else: bm = bmesh.new() bm.from_mesh(mesh) print(len(bm.verts)) # cycle through all vertices for vert in bm.verts: # check if the vertice is in the bounding vectors # if yes, select it # if no, deselect it if(IsInBoundingVectors(vert.co, vector1, vector2)): vert.select = True else: vert.select = False # update bmesh to mesh if bm.is_wrapped: bmesh.update_edit_mesh(mesh, False, False) else: bm.to_mesh(mesh) mesh.update() # trigger viewport update bpy.context.scene.objects.active = bpy.context.scene.objects.active # checks if a supplied coordinate is in the bounding box created by vector1 and vector2 and relies on vector1 being the "smaller" vector of the two def IsInBoundingVectors(vector_check, vector1, vector2): for i in range(0, 3): if (vector_check[i] <= vector1[i] or vector_check[i] >= vector2[i]): return False return True