remove vertices without edit mode

the question is pretty simple

how to remove some vertices without entering edit mode (in normal mesh or bmesh or anykind of mesh if it is possible)

eh? confused. you have to be in edit mode to select verts, so how exactly would you want to specify which verts to remove in non-edit mode… do you mean with python api?

Standard API doesn’t seem to support it (low-level), probably 'cause you would have to remove loops, edges and faces along with it. But Bmesh module supports it, even in object mode:


import bpy
import bmesh


def main(context):
    me = context.object.data
    bm = bmesh.new()
    bm.from_mesh(me)
    for v in bm.verts:
        if v.index % 3 == 0:
            bm.verts.remove(v)
    bm.to_mesh(me)
    me.update()




class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"


    @classmethod
    def poll(cls, context):
        return (context.object is not None and
                context.object.mode == 'OBJECT' and
                context.object.type == 'MESH')


    def execute(self, context):
        main(context)
        return {'FINISHED'}




def register():
    bpy.utils.register_class(SimpleOperator)




def unregister():
    bpy.utils.unregister_class(SimpleOperator)




if __name__ == "__main__":
    register()


    # test call
    bpy.ops.object.simple_operator()

well thanks for help:)
but I wanted to do this to avoid slow operations (as with large number of vertices entering edit mode and object mode each frame will cost a lot of time)
here too in from mesh and to mesh are taking time (they are copying which will be slow)

well as I think that mesh.vertices it self is a LIST,can i do direct list operations on them with any kind of hacks? like slicing,etc

I had to face the same problem, I’m porting a script from 2.49 to 2.66 and it seems that the only way to do that is to work on a temporay list to be than converted using from_pydata or to transit by a bmesh. The mesh control was much more simple and efficient in 2.49 as you could remove vertices, add faces and uvs directely in the corresponding lists without having to work on a temporay table or convert the mesh into bmesh first. Also I noticed that the converted script is about 25% slower in 2.6 than in 2.49. Duno why they complicated the process this way ? Maybe I missed something …

speed ? how about using GPU to process data

if you have cuda you could use it to port your script on GPU and do the math there!
that should be fast enought !

happy blendering

@RickyBlender … by the way I’m using OpenCL …lol?
the whole bottle neck in the process is Blender itself …I wanted to make a decent particle system on GPU using mesh vertices instead of Blender particles …but the simple fact that I can’t remove vertices by index without entering EDIT mode is a FAIL

@RickyBlender: it’s not about computing speed, but Blender 2.6x being slower than 2.4x and not providing standard low-level API to do certain things like removing verts.

here too in from mesh and to mesh are taking time (they are copying which will be slow)

Sure there’s always some overhead. But if you are in editmode and use bmesh.from_edit_mesh, there is no copying?! You delete verts, then flush by bmesh.update_edit_mesh(me). This is basically forwarding edits to the actual mesh without using a copy; requires a wrapped bmesh object (bmesh object magically linked to an edit mesh).