Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
On 28/08/2018 at 02:32, xxxxxxxx wrote:
Hi there,
i'm failing to get a submenu with a commanddata plugin... could anybody more experienced maybe have a look at this code?
best, index
my folder structure is: plugins Test test.pyp icon.png
what i would like to get in the plugin menu is: Plugins Test Plugin Submenu1 Submenu2
but what i get with the following code is just: (no submenu!) Plugins Test
import c4d from c4d import bitmaps import os.path
PLUGIN_ID = 1234567 # unique ID (obtained from www.plugincafe.com) PLUGIN_SHORT = "Test Plugin"
MENUID_SUB1 = 1000 MENUID_SUB2 = 1010
class MenuHandler(c4d.plugins.CommandData) :
def Register(self) : bmp = bitmaps.BaseBitmap() dir, f = os.path.split(\__file\_\_) fn = os.path.join(dir, "icon.png") bmp.InitWith(fn) return c4d.plugins.RegisterCommandPlugin( id=PLUGIN_ID, str=PLUGIN_SHORT, info=c4d.PLUGINFLAG_COMMAND_HOTKEY, icon=bmp, help="", dat=self ) def GetSubContainer(self, doc, submenu) : bc = c4d.BaseContainer() bc.SetString(1, PLUGIN_SHORT) bc.SetString(MENUID_SUB1, "Submenu1") bc.SetString(MENUID_SUB2, "Submenu2") submenu.InsData(0, bc) return True def ExecuteSubID(self, doc, id) : if id == MENUID_SUB1: print "Submenu1" elif id == MENUID_SUB2: print "Submenu2" return True def Execute(self, doc) : return True
if __name__ == "__main__": MenuHandler().Register()
On 29/08/2018 at 00:03, xxxxxxxx wrote:
strange! if i add a copy of this source in the same plugin folder then i get two plugin entries, both with the two desired submenus:
folder structure: plugins Test test1.pyp test2.pyp icon.png now i get: Plugins Test Test1 Plugin Submenu1 Submenu2 Test2 Plugin Submenu1 Submenu2
but if i remove one pyp, the remaining one does not show the submenus! how can i use only one pyp and show a submenu?
???
On 30/08/2018 at 01:17, xxxxxxxx wrote:
no help here? i tried for hours, but still cant create a plugin with a sub menu to execute different actions
On 30/08/2018 at 03:03, xxxxxxxx wrote:
Hi,
Sorry for the late answer.
There are limitations with GetSubContainer() and the "Plugins" menu. If there is only one plugin registered then its menu structure returned by GetSubContainer() is not taken into account. But if the plugin is added to another menu then it is shown as expected.
So the solution is to register a CommandData plugin with c4d.PLUGINFLAG_HIDEPLUGINMENU flag. Then the plugin can be added to any other menu either manually or with code using the menu functions in c4d.gui module.
On 30/08/2018 at 03:36, xxxxxxxx wrote:
thanks yannick,
i actually had that idea this morning, but couldnt make it work
i added a 2nd pyp to the plugin with c4d.PLUGINFLAG_HIDEPLUGINMENU but the main pyp didnt show its submenu then
are you sure this works? (maybe i dont understand correctly) it also needs a bogus plugin id, which is a bit odd, right?
another approach i'm trying is: generate a PopupDialog and show it with ShowPopupDialog when the menu is selected (works already) but i would also like to be able to have a drag off window with the (main) menu items as buttons that could be generated by opt-selecting the menu (any tips on how to create such a window?)
best index
On 30/08/2018 at 14:58, xxxxxxxx wrote:
a followup question to the post above:
ShowPopupDialog() has these flags c4d.POPUP_ALLOWUNDOCK c4d.POPUP_ALLOWUNDOCK_REC
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.gui/index.html?highlight=first_popup_id#c4d.gui.ShowPopupDialog
what are these for? i was hoping that you get a drag off handle, but i cant see anything happen if i use these flags
is there a way to make a PopupDialog sticky? or can i create a palette containing my command?
On 31/08/2018 at 00:22, xxxxxxxx wrote:
Your workaround with a popup dialog sounds too hacky to me.
The command can be registered with c4d.PLUGINFLAG_HIDEPLUGINMENU flag (plugin won't be shown in "Plugins" menu). Then manually add the command to any other menu/command palette with "Customize Commands" and "Customize Menu". The menu structure returned by the command's GetSubContainer() should be dynamically added as expected.
Note it is possible to customize the Cinema menu by code from a plugin.
If you have questions related to another subject, please create a new thread.