Pie Menu Editor 1.18.7

Add a Stack Key with D hotkey, Mesh keymap and this code (Command tab):

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); open_menu("108 D Edge") if num_sel_edges == 0 else bpy.ops.mesh.merge(type='COLLAPSE')

Don’t forget to unset D hotkey for 108 D Edge macro.

Or import this file


If you prefer poll methods use this code:
No selected edges:

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return num_sel_edges == 0

1+ selected edges:

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return num_sel_edges > 0
4 Likes