I'm trying to access to new vertices after apply bmesh.ops.bisect_edges

API say that newly created vertices and edges will be in geom_split. I can print"geom_split" data, but I can't access to new vertices, only I can see the information in console.

here code... thanks for any help

import bpy
import bmesh
import mathutils
import math

obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)

edges= [e for e in bm.edges if (e.select==True and not e.hide)]

if len(edges) < 2:
    print("please select minimun 2 edges")

    newmesh = bmesh.ops.bisect_edges(bm, edges=edges, cuts=5) #for example 5 cuts

    bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')

bmesh.update_edit_mesh(me, True)

bmesh.ops.bisect_edges returns a dictionary that only has one item geom_split, that one item is a list of the data you want. You can easily find what everything is in the python console -

>>> newmesh.keys()
>>> newmesh['geom_split'].keys()
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'list' object has no attribute 'keys'
>>> len(newmesh['geom_split'])
>>> type(newmesh['geom_split'][0])
<class 'BMVert'>
>>> type(newmesh['geom_split'][11])
<class 'BMEdge'>

If you replace your print() with the following you can see the returned data.

for i in newmesh['geom_split']:
    if type(i) == bmesh.types.BMVert:
        print("Vertex",i.index,"positioned at",i.co)
    elif type(i) == bmesh.types.BMEdge:
        print("Edge from vert",i.verts[0].index,"to vert",i.verts[1].index)

While the api states that bisect_edges returns "newly created vertices and edges" I only see two edges returned.

  • $\begingroup$ really thanks, this open some new windows for my developments $\endgroup$
    – yhoyo
    Jan 27 '15 at 23:37
  • $\begingroup$ For reference I reported a bug for the return value of bisect_edges, so this function may return more edges in later versions unless they change the docs to match the way it works now. $\endgroup$
    – sambler
    Jan 28 '15 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.