Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Login

    How to: Plugin parent folder on extensions menu

    Cinema 4D SDK
    python
    3
    5
    887
    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.
    • C
      cybor09
      last edited by

      Hello!

      I want to ask if someone knows how to add a "parent" plugin folder into the Extensions menu like this example:

      ee32d53a-4e03-454f-b5ce-73d78c963904-image.png

      I saw the CV-ArtSmart .pyp but I didn't understand how to put that parent and all the plugins inside of it.

      I discovered if I create one folder on the plugins folder, and them each children plugin as folders it will appears as I want but that's not the most efficient way to do it if the plugins will share data that I need to duplicate on each sub folder, what's why I'm trying to get a solution similar to this example.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov
        last edited by

        Hi @cybor09,

        Thanks for reaching out to us. You can achieve such grouping by simply registering your plugins in a regular way (please find a code snippet below). It's a default behavior that organizes all your plugins under a folder named after your plugin folder.

        Let me know if you have any further questions.

        Cheers,
        Ilia

        d67c9b38-b8c0-4f73-ab5e-7d695b33af9a-image.png

        *.pyp file content:

        import c4d, os
        from c4d import gui
        
        PLUGIN1_ID = 999121031
        PLUGIN2_ID = 999121032
        PLUGIN3_ID = 999121033
        
        class PC_12103_1(c4d.plugins.CommandData):
            def Execute(self, doc):
                print("Execute the 1st command")
                return True
        
        class PC_12103_2(c4d.plugins.CommandData):
            def Execute(self, doc):
                print("Execute the 2nd command")
                return True
        
        class PC_12103_3(c4d.plugins.CommandData):
            def Execute(self, doc):
                print("Execute the 3rd command")
                return True
        
        def loadIconBMP(iconName: str) -> c4d.bitmaps.BaseBitmap:
            directory, _ = os.path.split(__file__)
            fn = os.path.join(directory, "res", iconName)
            # Creates a BaseBitmap
            bmp = c4d.bitmaps.BaseBitmap()
            if bmp is None:
                raise MemoryError("Failed to create a BaseBitmap.")
            # Init the BaseBitmap with the icon
            if bmp.InitWith(fn)[0] != c4d.IMAGERESULT_OK:
                raise MemoryError("Failed to initialize the BaseBitmap.")
            return bmp
        
        if __name__ == "__main__":
            c4d.plugins.RegisterCommandPlugin(PLUGIN1_ID, "1st Cmd", 0, loadIconBMP("icon1.tif"), "", PC_12103_1())
            c4d.plugins.RegisterCommandPlugin(PLUGIN2_ID, "2nd Cmd", 0, loadIconBMP("icon2.png"), "", PC_12103_2())
            c4d.plugins.RegisterCommandPlugin(PLUGIN3_ID, "3rd Cmd", 0, loadIconBMP("icon3.png"), "", PC_12103_3())
        

        Plugin folder structure:
        8e76bb36-3c3c-49f4-9c88-3bf7600fdc90-image.png

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • C
          cybor09
          last edited by

          That's great, thanks a lot for your answer @i_mazlov , may I ask if is possible to add also an Icon to the parent folder? and if is possible to add subfolders too like on the scripts?

          Thanks again.

          1 Reply Last reply Reply Quote 0
          • i_mazlovI
            i_mazlov
            last edited by

            Hi @cybor09,

            You can group your plugins the way you described in your thread-starting posting. Another option is to build your custom menu using c4d.C4DPL_BUILDMENU.

            Adding icon to the parent folder doesn't seem to be possible unless using custom menu approach that I mentioned above.

            Let me know if you have any further questions.

            Cheers,
            Ilia

            MAXON SDK Specialist
            developers.maxon.net

            J 1 Reply Last reply Reply Quote 0
            • J
              jana @i_mazlov
              last edited by

              Hello @cybor09 ,

              without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly.

              Thank you for your understanding,
              Maxon SDK Group

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