PythonAPI: BMLoopUV.select_edge never returns True and doesn't update uv select state when set manually. #65836

Closed
opened 2019-06-15 20:53:16 +02:00 by eldee smith · 10 comments

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: blender/blender@d62a749fcf
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.

uvloop_bug.blend

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()

**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: `blender/blender@d62a749fcf` 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. [uvloop_bug.blend](https://archive.blender.org/developer/F7104657/uvloop_bug.blend) 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() ```
Author

Added subscriber: @testure

Added subscriber: @testure

Added subscriber: @kioku

Added subscriber: @kioku
Campbell Barton was assigned by Sebastian Parborg 2019-06-20 15:41:37 +02:00
Author

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
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 ```
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:34:05 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

@ideasman42 : MLOOPUV_EDGESEL is not set anywhere [code is relying on MLOOPUV_VERTSEL everywhere afaict].
Could look into this, but not sure how behavior here should be regarding select_edge? Should the flag be set if any neighbor MLoopUV is selected (feels ambiguous)?

@ideasman42 : `MLOOPUV_EDGESEL` is not set anywhere [code is relying on `MLOOPUV_VERTSEL` everywhere afaict]. Could look into this, but not sure how behavior here should be regarding `select_edge`? Should the flag be set if **any** neighbor `MLoopUV` is selected (feels *ambiguous*)?

This variable should probably be removed.

This variable should probably be removed.

This issue was referenced by blender/blender@9fa29fe765

This issue was referenced by blender/blender@9fa29fe7652a9adc4a11ba3dc2975595489f7bcd
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Philipp Oeser self-assigned this 2020-03-06 12:03:31 +01:00
Member

@testure: this has now been properly removed, leaving you with your workaround which seems good.

@testure: this has now been properly removed, leaving you with your workaround which seems good.
Sign in to join this conversation.
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#65836
No description provided.