Post #4700: Hello.

📋 Metadata

  • Author: Pluglug
  • Date: 2023-04-21 13:35:07
  • Type: answer
  • Quality Score: 9/10
  • Reply to: post_04699

🏷️ Tags

macro scripting advanced solved

  • Macro Editor
  • Python Scripting
  • Pie Menu Editor

💬 Content

Hello.
If you want to get the number of selected elements in Mesh Edit Mode, use bmesh. However, I thought it would be tedious to write that process every time, so I created a function called get_mesh_selection.

Put this file in “pie_menu_editor\scripts\autorun”. Then restart Blender. (Restart your PC if necessary)
You can use it as gms() in the Pie Menu Editor.

This function returns a tuple of the number of currently selected vertices, edges, and faces. Your idea can be realized this way.

s = gms(); msm = C.tool_settings.mesh_select_mode; O.mesh.merge(type='CENTER') if msm[0] and s[0] == 2 else O.mesh.knife_tool('INVOKE_DEFAULT') if msm[0] and s[0] == 0 else None

Of course, this is a demonstration, so you can arrange it however you like; you can also look up gms() and mesh_select_mode[0] in the Poll method.

imageimage2560×1410 794 KB

(Sorry for the multiple edits. I hope this image explains how to use the function…)


❤️ 1 likes


🔗 View on Blender Artists