Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to place own materials into the root menu?

    SDK Help
    0
    14
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 27/02/2016 at 10:01, xxxxxxxx wrote:

      Originally posted by xxxxxxxx

      Well, the question was how to move menu items 
      from default "Root -> Shaders -> Your Plugin Folder -> Material ... " 
      to "Root -> Your Plugin Folder -> Material ... "
      i.e. one level up

      Well, then still using the menu functions is probably what you need. Have you looked at GetMenuResource() etc.?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 27/02/2016 at 10:10, xxxxxxxx wrote:

        GetMenuResource() does look like the best approach.  And you can do this in main.cpp using C4DPL_BUILDMENU (in PluginMessage() as shown in the sdk example code).

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 27/02/2016 at 10:31, xxxxxxxx wrote:

          ...and there are also other functions like SearchMenuResource etc. which might help as well.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 27/02/2016 at 14:31, xxxxxxxx wrote:

            Ok, this code inserts my custom category in the root menu of material creation:

            void MySearchMenuResource(BaseContainer* bc)
            {
            	if (!bc) return;
              
            	BrowseContainer browse(bc);
              
            	Int32 id = 0;
            	GeData * dat = nullptr;
              
            	while (browse.GetNext(&id, &dat))
            	{
            		if (id == MENURESOURCE_SUBMENU || id == MENURESOURCE_STRING)
            		{
            			MySearchMenuResource(dat->GetContainer());
            		}
            		else if (id == MENURESOURCE_COMMAND)
            		{
            			if (dat->GetString() == String("IDM_MNEU"))
            			{
            				BaseContainer sc;
            				sc.InsData(MENURESOURCE_SUBTITLE, String("Category In Root"));
            				sc.InsData(MENURESOURCE_COMMAND, String("PLUGIN_CMD_XXXXXX"));
            				
            				bc->InsDataAfter(MENURESOURCE_STRING, sc, dat);
            			}
            		}
            	}
            }
              
            void EnhanceMaterialMainMenu(void)
            {
            	BaseContainer *bc = GetMenuResource(String("M_MATERIAL_MANAGER"));
            	if (!bc) return;
              
            	MySearchMenuResource(bc);
            }
            

            But the command PLUGIN_CMD_123456 doesn't create any material (we asume that 123456 is material plugin ID). How to fix that?

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 27/02/2016 at 16:20, xxxxxxxx wrote:

              Check out this post:

              https://developers.maxon.net/forum/topic/6496/6986_placing-a-plugin-under-the-file-menu&KW=insert+menu

              Plus, yes, the plugin ID must be a real ID associated with a material/shader plugin.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 28/02/2016 at 01:19, xxxxxxxx wrote:

                Sure, instead of the digits in the string PLUGIN_CMD_123456 I write a real plugin id of material (derived from MaterialData) but it doesn't work. If I write instead of these digits the plugin id of some command plugin it then works.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 28/02/2016 at 02:55, xxxxxxxx wrote:

                  If you cannot add materials that way you can always hide the original material entry (pass ~PLUGINFLAG_HIDE in RegisterMaterialData()) and create a commanddata plugin which creates the material (and then you can place the command in that menu instead)

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 28/02/2016 at 14:31, xxxxxxxx wrote:

                    Thanks Katachi, I have been also thinking about this not so elegant workaround. 
                    Maybe I will do it or will wait for what secret trick Sebastian can advice after the weekend 🙂

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 29/02/2016 at 02:33, xxxxxxxx wrote:

                      Hello,

                      I don't know any secret trick and I don't know what exactly Solid Angle did. But looking at the plugin it seems they created custom commands.

                      When Cinema registers a ObjectData plugin with RegisterObjectPlugin() internally also a command with the same ID is created. Because of this one can add such a command to a menu and one can use CallCommand() to create an object. When a material is registered no such internal command is created.

                      Best wishes,
                      Sebastian

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 01/03/2016 at 05:46, xxxxxxxx wrote:

                        Ok, thanks Sebastian for explanation! It seems that for this task we only can create many corresponding command plugins with doc->InsertMaterial() inside.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post