TransWikia.com

Detect if any edge/edges are selected in a mesh

Blender Asked by Retrax on December 30, 2021

How do I detect if any edges are selected in the mesh in context ?

Im trying to enable or disable a class by this polling method which detects the object type and mode of the object but Im trying add detection of any selected edges to the polling

@classmethod
def poll( self, context ):
    return context.object and context.object.type == 'MESH' and context.active_object.mode == 'EDIT'

One Answer

@classmethod
def poll( self, context ):

    #Get active object
    act_obj = context.active_object

    #Check for edit mode and mesh type        
    if act_obj.mode == 'EDIT' and act_obj.type == 'MESH':
        
        #Get selected edges from bmesh        
        me = act_obj.data
        bm = bmesh.from_edit_mesh(me)

        edges_selected = [e for e in bm.edges if e.select]
    
        return edges_selected

Answered by AFWS on December 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP