Page MenuHome

BMesh BMVert.copy_from(other) kills the vert
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.20

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: rBf6cb5f54494e
Worked: (optional)

Short description of error
Creating a vert with v = bmesh.verts.new(), and then calling v.copy_from(other_vert) makes v a dead vert

Exact steps for others to reproduce the error

This gives an error

import bmesh

def main():
    bm = bmesh.new()
    v0 = bm.verts.new((1, 1, 1))
    v1 = bm.verts.new((0, 0, 0))
    v1.copy_from(v0)
    bm.edges.new((v0, v1))
    #TypeError: edges.new(...): 1 BMVert has been removed

    bm.free()

if __name__ == "__main__":
    main()

whereas

import bmesh

def main2():
    bm = bmesh.new()
    v0 = bm.verts.new((1, 1, 1))
    v1 = bm.verts.new((0, 0, 0))
    v1.co = v0.co
    bm.edges.new((v0, v1))
    bm.free()

if __name__ == "__main__":
    main2()

works.

copy_from returns None, so I'm not sure how else if should be used. Maybe I'm missing something, but I expected v1 in the above not working code to be a live vert with the same data values as v0. Is that not the intended operation of copy_from?

Event Timeline

I can confirm, but I can't tell if this is expected or not.
The manual doesn't say much: https://docs.blender.org/api/current/bmesh.types.html#bmesh.types.BMVert.copy_from

@Campbell Barton (campbellbarton), is this expected or does BM_elem_attrs_copy copy something it shouldn't?

I have a fix, will commit tomorrow since it's a larger change than I expected.