0
$\begingroup$

I'm trying to iterate through multiple selected objects and perform bmesh operations. Unfortunately, I get errors such as index 0 out of range when trying to perform basic tasks such as selecting vertex index 0 on the next object in the selection.

I can iterate through objects and perform bpy operations, and I can perform bmesh operations on single objects fine. Unfortunately I get stuck when I try to perform index specific bmesh operations when iterating through all selected objects.

Would anyone be able to give me a basic example that would iterate through selected objects and e. g delete vertex with an index of 0 using bmesh? I'm using Blender 2.8

Thanks.

$\endgroup$
2
  • 2
    $\begingroup$ Example of bmesh operation on multiple objects blender.stackexchange.com/a/128263/15543 $\endgroup$
    – batFINGER
    Commented Oct 7, 2019 at 8:41
  • $\begingroup$ Thanks, that gave a great example, just what I was after. $\endgroup$
    – James
    Commented Oct 7, 2019 at 17:48

1 Answer 1

2
$\begingroup$

This is an example based upon batFINGER's link that uses a vertex index.

import bpy
import bmesh

context = bpy.context
mesh_obs = [o for o in context.selected_objects if o.type == 'MESH']
bm = bmesh.new()

for ob in mesh_obs:
    me = ob.data
    bm.from_mesh(me)

    bm.verts.ensure_lookup_table()
    bm.verts.remove(bm.verts[0])

    bm.to_mesh(me)
    me.update()
    bm.clear()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .