What is mean "2&c&" in Python

  • Hi Plugincafe!
    I'm a new python guy and my english is so poor...
    I can't understand what is "&c&" ,"&d&" and "&i&" in ShowPopupDialog.
    How do they work in Python ??

  • "&c&" will add a checkmark in the menu item,
    "&d&" will disable the menu item (user is unable to select it)
    This is not Python related, it's just a way of defining extra options for menu items, by including it in the menu item text.

  • @C4DS Thank you very much!
    and i have another question;
    if "item 1" is checked; my object solo in viewport.
    and "item 2" is checked; my object is not solo.
    (hope you understand this question😊 )

  • @gheyret
    I am not sure to understand your question, since it's technically only two statements.
    However, if I assume correctly, you are trying to solo an object by using "item 1" and not solo that object by using "item 2"?
    This doesn't make sense to me, since you have 2 booleans to control a single state (solo / not solo) while the combinations of the 2 booleans provide 4 possible results.
    I would expect you only have "item 1" and use its state (checked / unchecked) to control solo / not solo.

    Another solution would be that each "item x" changes the state of the other "item y".

  • @C4DS
    Maybe my question is not quite right.
    Here's the thing:
    i have a cube object,if "item 1" is checked,the cube object solo on viewport.if "item1"is unchecked,the cube object is not solo.
    Can you give me a simple exaple for this?

  • @gheyret said in What is mean "2&c&" in Python:

    Can you give me a simple exaple for this?

    It would be easier to explain when you show the implementation you have so far to set up the dialog and handle the selected menu items? At least then we have some context to start from.

  • @C4DS I just want to understand how it works.(Checked, add event, uncheck)

  • Hello and welcome to the PluginCafe.

    ShowPopupDialog() returns the ID of the selected item. With that ID you can decide what to do next.

    What do you mean with "solo in viewport"?

    Do you mean the Viewport Solo Mode or the layer solo mode?

    You can switch the viewport solo mode using the associated commands. You can call a command using CallCommand() and the associated ID. The ID can be found in the "Customize Commands" manager.

    # check if object is selected
    if op is None:
    # menu
    menu = c4d.BaseContainer()
    menu.InsData(IDM_MENU1, 'Solo')
    menu.InsData(IDM_MENU2, 'Non-Solo')
    # show and get result
    result = gui.ShowPopupDialog(cd=None, bc=menu, x=300, y=300)
    if result == IDM_MENU1:
        # set solo
        # set non-solo

    Also, please use the Q&A system.

    best wishes,

  • @s_bach Thank you so much.
    Actually, I want to know if i click "item1" in the Popup dialog,the "item1"is checked,and if i click "item2" in the popup dialog,than "item2" is checked.like display filter in the viewport menu.

  • Hello,

    the "checked" state does not have any functionality. It is just a visual marker for your user.

    Or to put it differently: you don't need to read if an element is "checked" since you yourself set this "checked" state in the first place when you create the menu with ShowPopupDialog().

    best wishes,

Log in to reply