Search code examples
python3dblendermeshunwrap

Converting Blender's UV vectors into 3D coordinates


I have converted a UV vector coordinates into 3D plane using Blender's Bmesh function. Using bmesh to create the newer mesh,

bm.faces.new((vert))

it creates faces that is undesirable, or more accurately, the edges and faces that are generated by the function are not as intended.

Is there a way to allow no generation of edges that are more than the maximum connected distance of a mesh using bmesh?

This picture shows generation of both edges and faces on the left marked out in green, comparing with the seam that I have marked for UV unwrapping.


Solution

  • Each face has a list of edges, an edge can give you it's length and if it's too long you can remove it. Removing one of the edges will also delete the face.

    f = bm.faces.new((vert))
    for e in f.edges:
        if e.calc_length() > max_length:
            bm.edges.remove(e)
    

    You can also get the distance between two vertices before using them to create a face (v1.co-v2.co).length, the trick is knowing which will be joined as edges and which will be diagonal across the face.