Add Title Items (not packable) to Custom Menu
-
Hey Forum,
I have two questions for you.
- Is there a way to add not pickable items like a title written with capital letter to custom menus created by python.
- How a toggle line be added and how can be get its sate ?
I added a part of my code above where the str item is not working sadly.
THanks,
G...
def insert(root: c4d.BaseContainer, title: str, data: MenuData) -> c4d.BaseContainer: """Inserts #data recursively under #root under the entry #title. """ # Create a new container and set its title. subMenu: c4d.BaseContainer = c4d.BaseContainer() subMenu.InsData(c4d.MENURESOURCE_SUBTITLE, title) # Iterate over the values in data, insert commands, and recurse for dictionaries. for key, value in data.items(): if isinstance(value, dict): subMenu = insert(subMenu, key, value) elif isinstance(value, int): subMenu.InsData(c4d.MENURESOURCE_COMMAND, f"PLUGIN_CMD_{value}") elif value is None: # Insert a separator subMenu.InsData(c4d.MENURESOURCE_SEPARATOR, None) elif isinstance(value, str): # Add a non-clickable title subMenu.InsData(c4d.MENURESOURCE_STRING, value) root.InsData(c4d.MENURESOURCE_SUBMENU, subMenu) return root
-
Hey @Gemini,
Thank you for reaching out to us. I am struggling a bit with understanding all details of your question(s). Please also note that we do not allow for multi question topics, see Support Procedures: How to ask Questions for details.
Is there a way to add not pickable items like a title written with capital letter to custom menus created by python.
I assume you are talking about sub-titles in menus here, @i_mazlov has shown here how to do that.
How a toggle line be added and how can be get its sate?
I assume you mean here a menu entry with a checkbox/checkmark next to it? Menus allow you to mark entries as checked or disabled with the label suffixes 'c' and 'd'. E.g.:
"I am a checked label&c&"
and"I am a disabled label&d&"
. See ShowPopupDialog() for an example. But one usually does this on a popup menu or dialog menu level.The code you show us as "yours", is code I have written in the context of the main menu of Cinema 4D. So, the question is: Do you want to inject things into the main menu of Cinema 4D, or are you just populating a dialog or popup menu.
I am not sure if you are allowed to place checkmarks there and manually disable menu entries, as Cinema 4D itself owns its main menu. It might ignore such markup there, you would have to try yourself.
Cheers,
Ferdinand -
Hi, thanks for your answer. I'd like to add a title line like here for example the 'DINAMICS' line.
G -
Well, my answer answers that, check out the posting I linked to. You must insert a
MENURESOURCE_SUBTITLE
:menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Heading")