So I wrote a script to select a certain set of edges that I'd like to bevel. I save the edges inside of a dictionary with the key being the indices of the vertices on that edge and the value being the weight of the beveling. The edges are guaranteed to be separate. Which mean they don't share any common vertex. But some of them need more segment and width, some of them need less depending on the angle between the faces it lays on. I tried using the bevel modifier but it only either bevel by weight OR by angle and not both. I also tried manually beveling each edge but after one bevel, the indices are all messed up and the algorithm can't find the edges anymore. Is there a way to achieve this?


1 Answer 1


As the index of an item changes as edits are made to the mesh you need to get each edge object before making any changes, then refer to each edge as you do the bevel. You can use the edges verts property to get the vertices at each end.

import bpy, bmesh

me = bpy.context.edit_object.data

# edge_bevel_data
ebd = [
{'idx': 13, 'edge': None, 'offset': 0.05, 'segments': 3},
{'idx': 32, 'edge': None, 'offset': 0.04, 'segments': 2},
{'idx': 89, 'edge': None, 'offset': 0.06, 'segments': 3},

bm = bmesh.from_edit_mesh(me)

# first get the edges
for i in range(len(ebd)):
    ebd[i]['edge'] = bm.edges[ebd[i]['idx']]

# bevel each edge
for i in range(len(ebd)):
    e = ebd[i]['edge']
    bev_geom = [e.verts[0], e.verts[1], e]
    o = ebd[i]['offset']
    s = ebd[i]['segments']
    bmesh.ops.bevel(bm, geom=bev_geom, offset=o, segments=s)

bmesh.update_edit_mesh(me, True)
  • $\begingroup$ If I understand it correctly, you refer to the edge as the object instead of the index? $\endgroup$
    – Jack Le
    Commented Apr 10, 2016 at 17:33
  • $\begingroup$ For some reason blender crashes at bmesh.ops.bevel(bm, geom=bev_geom, offset=o, segments=s) $\endgroup$
    – Jack Le
    Commented Apr 10, 2016 at 18:59
  • $\begingroup$ @JackLe - bad values of geom will do that. The geom value is a list of BMVert/BMEdge/BMFace - if you only have an edge it crashes, if the verts don't match the edge it crashes.... $\endgroup$
    – sambler
    Commented Apr 11, 2016 at 16:56
  • $\begingroup$ But I used the vertices on that same edge like you did. I even tried doing it separately in the command line. It still crashed. $\endgroup$
    – Jack Le
    Commented Apr 12, 2016 at 15:04
  • $\begingroup$ Odd - the only time I can get it to crash is as I mentioned above. Have you tried with a different mesh, I have used an icosphere and subdivided cube and checked back to 2.73. Bevel only happens if there is a face on both sides of an edge but I only get it to crash by changing the bev_geom=[] line. $\endgroup$
    – sambler
    Commented Apr 12, 2016 at 16:09

You must log in to answer this question.

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