0
$\begingroup$

I've been using Pie Menu Editor and I'd like to create one that activates only in object mode when nothing is selected. I did a lot of research but since I have no background in coding it makes it very hard for me.

The idea is to have one pie menu to create meshes when nothing is selected and another one with the same shortcut to merge two meshes together for instance.

It seems like it has to do with poll options. An example they give for instance if you want to create a pie menu that activates only while in edge mode you have to write : return C.scene.tool_settings.mesh_select_mode[1]

Thank you for your help :)

$\endgroup$

1 Answer 1

0
$\begingroup$

I found a way !!!

return len(bpy.context.selected_objects) == 0

This works just fine :)

$\endgroup$
3
  • 2
    $\begingroup$ It might be better to use context than bpy.context $\endgroup$
    – HikariTW
    Commented Sep 10, 2019 at 22:48
  • 2
    $\begingroup$ May I know why ? $\endgroup$
    – Poppip
    Commented Sep 11, 2019 at 19:15
  • $\begingroup$ So other script, that are run in different contexts can call your operator (even from the wrong context) by passing whichever context they want to. Unlikely in your pie menu case. $\endgroup$
    – Leander
    Commented Apr 6, 2023 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .