0
$\begingroup$

Not massively familiar with blender and looking at: https://docs.blender.org/api/blender_python_api_current/bmesh.utils.html?highlight=edge_split#bmesh.utils.edge_split

It's not clear what the value of the 'fac' argument is supposed to be? Is it a 3d coord? (x, y, z) or something else, like a fraction of the total length of the edge?

What's a good way to calculate it? As examples there's this: https://github.com/lijenstina/mesh_extra_tools/blob/c90634a024ab8d531751df873d33dbe905d0ca13/mesh_extrude_and_reshape.py#L217

But want to confirm calculating the distance between the edge's two vertices is necessary.

$\endgroup$
2
$\begingroup$

'fac' is a percent of the edge length, considered from the vertex indicated in the call.

For instance, if you run the code below on an edge suite, you'll see the growing percents applied on a length of 2 meters:

enter image description here

import bpy, bmesh


obj = bpy.context.object

if obj is not None:

    prevMode = obj.mode

    try:
        bpy.ops.object.mode_set(mode='EDIT', toggle=False)

        bm = bmesh.from_edit_mesh( obj.data )

        edgeCount = len(bm.edges)

        for i, e in zip( range(edgeCount), sorted( bm.edges, key=lambda e: e.verts[0].co[2] ) ): #Indexes and sorted edges from bottom to top
            fac = (i+1) / 10
            print(fac)
            ne, nv = bmesh.utils.edge_split( e, e.verts[0], fac)
            print(ne,nv)

    finally:   
        bpy.ops.object.mode_set(mode=prevMode, toggle=False)
$\endgroup$

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.