<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CommandData Plugin with Submenu]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">below is a simple CommandData plugin with a submenu to invoke different actions.</p>
<p dir="auto">This works fine if more than one of these plugins (with unique Plugin Ids ofc) are in one plugin folder.<br />
But there is no menu if there is only one plugin present in the folder.</p>
<p dir="auto">Is there a way to create such a menu with one plugin, while not registering each menu point as separate command?</p>
<p dir="auto">best index</p>
<pre><code># encoding: utf-8

''' CommandData Plugin with Menu '''

import c4d 

PLUGIN_ID = 12345678  # Unique Plugin Id

MENUID_CMD0 = 1000
MENUID_CMD1 = 1001

class MenuHandler(c4d.plugins.CommandData):

	def Register(self):
		return c4d.plugins.RegisterCommandPlugin(
			id=PLUGIN_ID, str="Test", info=c4d.PLUGINFLAG_COMMAND_HOTKEY, icon=None, help=None, dat=MenuHandler())

	def GetSubContainer(self, doc, submenu):
		bc = c4d.BaseContainer()
		bc.SetString(1, "Test")
		bc.SetString(MENUID_CMD0, "Command 0")
		bc.SetString(MENUID_CMD1, "Command 1")
		submenu.InsData(0, bc)
		return True

	def ExecuteSubID(self, doc, id):
		if id == MENUID_CMD0:
			pass
		if id == MENUID_CMD1:
			pass
		return True

	def Execute(self, doc):
		return True

if __name__ == "__main__":
	MenuHandler().Register()
</code></pre>
]]></description><link>http://developers.maxon.net/forum//topic/12910/commanddata-plugin-with-submenu</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Mar 2026 11:26:35 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum//topic/12910.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Sep 2020 11:13:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Tue, 15 Nov 2022 17:35:34 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, Manuel</p>
<p dir="auto">I do not mean to stress anybody.<br />
But I'd say, this is quiet basic plugin functionality, which by now is not working for more than two years. So, i thought, I'd ask, if there's a chance for a fix.</p>
]]></description><link>http://developers.maxon.net/forum//post/70174</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70174</guid><dc:creator><![CDATA[a_block]]></dc:creator><pubDate>Tue, 15 Nov 2022 17:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Tue, 15 Nov 2022 16:11:40 GMT]]></title><description><![CDATA[<p dir="auto">hi Andreas,</p>
<p dir="auto">this is an old bug; I've created a new bug entry trying to describe the problem the best i can. This is not super obvious to understand where to add the fix and what the fix will be.</p>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum//post/70173</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70173</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Tue, 15 Nov 2022 16:11:40 GMT</pubDate></item><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Fri, 11 Nov 2022 11:31:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
are there any chances this will ever get fixed?<br />
Cheers,<br />
Andreas</p>
]]></description><link>http://developers.maxon.net/forum//post/70135</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/70135</guid><dc:creator><![CDATA[a_block]]></dc:creator><pubDate>Fri, 11 Nov 2022 11:31:52 GMT</pubDate></item><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Wed, 30 Sep 2020 12:40:19 GMT]]></title><description><![CDATA[<p dir="auto">hi,</p>
<p dir="auto">To have a sub menu, you need to register more than one plugin.<br />
If you add an extra folder (//User/PluginDirectory/Menu) and make cinema4D point to <code>PluginDirectory</code>. An extra level will be created in the menu named in that example <code>Menu</code>.</p>
<p dir="auto">Interesting fact. If you register two command, and one have SubID Registered, than the SubID works as expected. (this is obviously a bug)</p>
<p dir="auto">If you burry the following code inside a sub folder, the second command will not appear, it's named "---" so should act as a separator. (but there's nothing to separate)<br />
And you will be able to execute subIDs from the first command.</p>
<p dir="auto">I would not do that on a public plugins. This will not work if the user remove that extra folder.</p>
<pre><code>import c4d


MAIN_CMD_PLUGIN_ID  = 1055692
MAIN_CMD_PLUGIN_ID2  = 1055693



class MYCOMMANDWITHDIALOG (c4d.plugins.CommandData):

	def Execute(self, doc):
		print ("execute")
		return True

	def GetSubContainer(self, doc, submenu):
		print ("getsubcontainer", doc, submenu)
		bc = c4d.BaseContainer()
		bc.SetString(1, "Create Primitives")
		bc.SetString(1000, "Create a cube")
		bc.SetString(1001, "Create a sphere")
		submenu.InsData(0, bc)
		return True
	
	def ExecuteSubID(self, doc, subid):
		print("execute subID", doc, subid)
		op = None
		if subid == 1000:
			 op = c4d.BaseObject(c4d.Ocube)
		elif subid == 1001:
			op = c4d.BaseObject(c4d.Osphere)
		
		
		if op is None:
			return False

		doc.InsertObject(op)

		return True

class Dummy (c4d.plugins.CommandData):

	def Execute(self, doc):
		return True



def main():

    c4d.plugins.RegisterCommandPlugin(id=MAIN_CMD_PLUGIN_ID,
                                str  ="Command with sub id",
                                info = 0,
                                help ="Command with sub command or dialog option",
                                dat = MYCOMMANDWITHDIALOG(),
                                icon=None)

    c4d.plugins.RegisterCommandPlugin(id=MAIN_CMD_PLUGIN_ID2,
                                str  ="---",
                                info = 0,
                                help ="DummyHiddenCommand",
                                dat = Dummy(),
                                icon=None)
if __name__ == '__main__':
	main()
</code></pre>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum//post/64527</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/64527</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Wed, 30 Sep 2020 12:40:19 GMT</pubDate></item><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Mon, 28 Sep 2020 20:57:25 GMT]]></title><description><![CDATA[<p dir="auto">hm, ok...</p>
<p dir="auto">but is this bug the reason, that there need to be more than one plugin in a plugin folder to get submenus?<br />
or in other words ... is it possible to create a submenu in the plugin menu with a single command data plugin?</p>
<p dir="auto">index</p>
]]></description><link>http://developers.maxon.net/forum//post/64510</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/64510</guid><dc:creator><![CDATA[indexofrefraction]]></dc:creator><pubDate>Mon, 28 Sep 2020 20:57:25 GMT</pubDate></item><item><title><![CDATA[Reply to CommandData Plugin with Submenu on Mon, 28 Sep 2020 12:11:50 GMT]]></title><description><![CDATA[<p dir="auto">hi,</p>
<p dir="auto">there's currently a bug with this function in python.<br />
(as i forgot to report <a href="https://developers.maxon.net/forum/topic/12840/commanddata-executeoptionid" target="_blank" rel="noopener noreferrer nofollow ugc">in this thread</a>)</p>
<p dir="auto">Cheers,<br />
Manuel</p>
]]></description><link>http://developers.maxon.net/forum//post/64501</link><guid isPermaLink="true">http://developers.maxon.net/forum//post/64501</guid><dc:creator><![CDATA[Manuel]]></dc:creator><pubDate>Mon, 28 Sep 2020 12:11:50 GMT</pubDate></item></channel></rss>