Post #4834: I’m glad the issue was resolved! In the case of `m = C.tool_settings.uv_select_m

📋 Metadata

🏷️ Tags

v1-18-7 macro python-scripting intermediate solved

  • Macro Editor
  • Python Scripting
  • Conditional Logic

💬 Content

I’m glad the issue was resolved! In the case of m = C.tool_settings.uv_select_mode; return m in ['VERTEX', 'EDGE'], I’m using a semi-colon to separate two commands in a single line because PME requires commands to be written in one line.

If there weren’t such constraints, you could write it as:

# Get the current value of uv_select_mode
current_mode = bpy.context.tool_settings.uv_select_mode

# Check if the current_mode is EDGE
if current_mode == 'EDGE':
    print("True. This means it's in Edge select mode.")
else:
    print("False. This means it's in a mode other than Edge.")

My initial example might have confused you. The first command assigns a value to m, and the second checks if m is in the list ['VERTEX', 'EDGE']. In other words, it returns True if the select mode is Vertex or Edge.

m = C.tool_settings.uv_select_mode; return m in ['VERTEX', 'EDGE']

To answer your new question: Yes, if you want to add a check for the number of verts, edges, faces, etc., you can separate the commands with a ;. However, when there’s more logic involved, it’s often clearer to use separate lines or define a more comprehensive function.

For the check on the number of vertices, edges, and faces, refer to my previous response. I’ve provided a script there to simplify the check, which you might find useful.

Pie Menu Editor 1.18.7 Released Scripts and Themes

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…

Is the Face menu not displaying for you? That’s odd. It might take a bit more time to verify the cause. I suspect it might be due to the evaluation order in the Poll. If that’s the case, we’ll consider other methods beyond the Poll.

Can you elaborate on the feature you would like to create?


❤️ 2 likes


🔗 View on Blender Artists