Is there a way to invoke bpy.ops.operation pop up menu in a similar way to pie menu editor?

Hi, I am currently working on an addon, but there’s a major problem I have had during the last days. I don’t quite understand how I can use “bpy.ops.mesh.select_linked_pick()” and get the menu options when using it from my addon script. An even bigger problem is that it does not work at all.
image
One workaround is to add it to a new shortcut instead, like “uv.select_linked_pick”.

This works, but I want it to be part of an operation class with other operations that can be executed/invoked from a single hotkey.

Is there anything special Pie Menu Editor does that makes it so you can invoke multiple “bpy.ops” operations in a row and invoke all of them correctly? While also getting a menu option with all the options for all of the bpy.ops operation, so for example if I use select linked and poke in a macro it will show settings for both in the options menu.
image

Hope this makes sense, thanks :slight_smile:

1 Like

similarly i have a command for “seams from flat face boundary selection” and the info editor appears these execution command from the PME macro operator:

bpy.ops.pme.macro_boundary_mark_seam(MESH_OT_faces_select_linked_flat={“sharpness”:0.0174533}, MESH_OT_region_to_loop={}, MESH_OT_mark_seam={“clear”:False})

maybe check on yours and see the command line it outputs…

in my little programing understanding i think you only you need to place the comma (,) to separate every command and probably parentheses/curly brackets for its internal options

EDIT: just tried that in the text editor and worked but very unintuitive to use in that manner imo:

import bpy
bpy.ops.mesh.region_to_loop(), bpy.ops.mesh.mark_seam(clear=False)

1 Like

Oh! Thanks! I never knew that about the comma! Doing this I get a more similar result comperd to Pie Menu Editor, but I still do not get any pop up menu at all comper to how it appears in Pie menu editor

my code:

import bpy

class DoubleClickPoke(bpy.types.Operator):
    bl_idname = "double.click_poke"
    bl_label = "Double Click Poke Island"
    bl_description = ""
    bl_options = {'REGISTER', 'UNDO'}  

    
    def execute(self, context):
        bpy.ops.mesh.select_linked_pick('INVOKE_DEFAULT'), bpy.ops.mesh.poke('INVOKE_DEFAULT')

        return {'FINISHED'}

No pop up menu after using the operation:

It’s been a while since I used PME, but I’m guessing it still uses native macros for chaining operators. Macros are like operators. They register and are called like operators, but they don’t define execution methods.

import bpy

class DoubleClickPoke(bpy.types.Macro):
    bl_idname = "double.click_poke"
    bl_label = "Double Click Poke Island"
    bl_options = {'REGISTER', 'UNDO'}  

if __name__ == "__main__":
    bpy.utils.register_class(DoubleClickPoke)

    DoubleClickPoke.define("MESH_OT_select_linked_pick")
    DoubleClickPoke.define("MESH_OT_poke")
2 Likes

Idk but you can try asking in the PME thread which you may have forgot to check Pie Menu Editor 1.18.7

1 Like

My guess is you are just using the operator and forgetting that the pop-up menu is a Menu( bpy.types.Menu (or the UI part) ).
See more on https://blender.stackexchange.com/questions/57306/how-to-create-a-custom-ui about custom UI elements and Ui elements overall.

For the Select Linked there can be a template of the menu already existing, or, in worst case scenario, you can do your custom menu and give all the options to draw in Custom_MenuName(bpy.types.Menu).

2 Likes

Oh! Thanks! Looking inside the code for PieMenu Editor, it indeed seems to be using bpy.types.Macro. I just tried it, and a menu does pop up, but sadly, no options inside of it. I will try to look more into how PME does it and hopefully figure something out. Thanks again!

Oh! That would make sense, will look into it! Many thanks for the suggestion! :slight_smile: