0
$\begingroup$

for example in this pie menu below

import bpy
from bpy.types import Menu

class Pie_menu(Menu):
    bl_label = "Some Pie Menu"
    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        pie.operator("wm.call_menu_pie", text = "Some Other Pie", icon = "RIGHTARROW_THIN").name="Pie_menu"
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.operator("mesh.primitive_cube_add", text = "Some Operator", icon = "BLENDER")
        pie.separator()
        pie.separator()
        other = pie.column()
        gap = other.column()
        gap.separator()
        gap.scale_y = 7
        other_menu = other.box().column()
        other_menu.scale_y=1.3


        if len(bpy.context.selected_objects) == 0:
            option = "option if nothing is selected"
        else:
            option="defaultoption"

        other_menu.operator("mesh.primitive_cube_add", text = option ,icon = "BLENDER")



def register():
    bpy.utils.register_class(Pie_menu)

def unregister():
    bpy.utils.unregister_class(Pie_menu)

#if __name__ == "__main__":
    #register()

    #bpy.ops.wm.call_menu_pie(name="Pie_menu")

there is a button with different functionalities, name, icon, (here its just the name) depending on a condition.

it work fine if i register this addon from the script, by removing the three # at the end and Running the script, but as soon as i register this as an addon, its not working anymore. Why ?

also in this same idea, how can i put a vaiable like that not in a form of a button but a simple text ?

$\endgroup$
3
  • $\begingroup$ it seems that we cannot put condition themself within the menu class SO if i wrote a custom proprety bpy.context.scene["Test"]="Adaptive Name" and them reffer this new name by bpy.context.scene["Test"]it can work ! $\endgroup$
    – Fox
    May 22, 2019 at 14:48
  • $\begingroup$ HI. If you have an answer, please place it in the answer box below, not in the comments. $\endgroup$ May 22, 2019 at 15:08
  • $\begingroup$ yes i needed to wait a bit $\endgroup$
    – Fox
    May 22, 2019 at 15:19

1 Answer 1

0
$\begingroup$

So i cannot write a condition directly on the pie menu BUT i can reffer the name,function and icon to an actual name inside of blender.

so i could create a custom properties just for the occasion

for example i can first add two custom properties with thoses codes:

bpy.context.scene["Name of my menu"]="Adaptive Name"
bpy.context.scene["Icon of my menu"]="BLENDER"

the only problem is that it need to be done BEFORE opening this pie menu. and you can do this with the followed technique:

class BackMeUpPie_OT_Operator(bpy.types.Operator):
    bl_idname = "view3d.pie"
    bl_label = "Back Me Up Pie Menu"
    bl_description = " OPERATOR DESCRIPTION HEYYYY"
    def execute(self, context): 
        try:
            bpy.context.window_manager["Auto-Copy Icon?"]+=1 #if i can do this its not the first time i launche the pie
        except:
            bpy.context.window_manager["Auto-Copy Icon?"] =1 #if i can't it is, so the timer cannot be
            bpy.context.scene["Auto-Copy"] = "OFF"
            bpy.context.scene["Auto-Copy Ic"] = "FAKE_USER_OFF"

        bpy.ops.wm.call_menu_pie(name="view3d.pie_backmeup")
        return {'FINISHED'}

creating an operator, that determine the icon, name..Ect.. of your cutom assets with the condition of your choice, like in this exemple above, and then just after opening your pie/menu

$\endgroup$

You must log in to answer this question.

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