Page MenuHome

PythonAPI: BMLoopUV.select_edge never returns True and doesn't update uv select state when set manually.
Open, Confirmed, MediumPublic

Description

System Information
Operating system: Linux-4.18.0-21-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: Mesa DRI Intel(R) Haswell Mobile Intel Open Source Technology Center 4.5 (Core Profile) Mesa 18.2.8

Blender Version
Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-03 19:00, hash: rBd62a749fcf48
Worked: (optional)

Short description of error
BMLoopUV.select_edge never returns True and doesn't update uv select state when set manually.

Exact steps for others to reproduce the error
See attached .blend file for exact/minimal repro. Contains an embedded script with a simple bmesh operator ("UVLoop Select Edge Bug"), when you run it with a selected edge in the UV editor it should print "THIS WILL NEVER HAPPEN" to the console, but obviously it does not. Script also contains simple logic to prove that the edge is selected by checking the next loop's select state.

Script, for posterity:

import bpy
import bmesh

def main(context):
    bm = bmesh.from_edit_mesh(bpy.context.edit_object.data)
    uv_layer = bm.loops.layers.uv.verify()   
    
    for face in bm.faces:
        for loop in face.loops:
            uvloop = loop[uv_layer]
            
            # BUG(?): -------------------------------------------
            # select_edge is always false, even if there is an edge selected!!
            next_loop = loop.link_loop_next
            next_uvloop = next_loop[uv_layer]
            
            if uvloop.select_edge:
                print("THIS WILL NEVER HAPPEN")                
            elif uvloop.select and next_uvloop.select:
                print(f"uvloop.select_edge for edge index {loop.edge.index} should have been True, but it wasn't!")
                
            #print(f"e{loop.edge.index}:\t{uvloop.select_edge}")
            # ---------------------------------------------------

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator_bug_test"
    bl_label = "UVLoop Select Edge Bug?"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()

Details

Type
Bug

Event Timeline

eldee smith (eldee) updated the task description. (Show Details)
Sebastian Parborg (zeddb) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.
eldee smith (eldee) added a comment.EditedJul 3 2019, 10:44 PM

For anyone else who might need this functionality, a workaround that I use is the following:

def is_uv_edge_selected( loop, uv_layer ):
        '''With a given loop, determine if the entire edge is selected in the UV editor.'''
        # NOTE: This helper function is only necessary because of a bug where BMLoopUV.select_edge does nothing: https://developer.blender.org/T65836
        return loop[ uv_layer ].select and loop.link_loop_next[ uv_layer ].select