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

    Custom register plugin

    Cinema 4D SDK
    6
    8
    1.5k
    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.
    • WickedPW
      WickedP
      last edited by

      Hi folks,

      just doing some brainstorming and hoping someone may be able to suggest/contribute some ideas.

      I have a dialog plugin with a graphical interface. I'd like to be able to register plugins for my plugin, so that I can build them separately if needed, or perhaps so others in the future may be able to.

      Is it possible to register a custom plugin type? Or, could I piggyback off one of the Register*() functions and grab the registration in my plugin somewhere?

      WP.

      wickedp.com

      C4DSC 1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS @WickedP
        last edited by

        @WickedP
        Not sure what you're after but you can always use a SpecialEventAdd in your "separate" plugin to communicate with your dialog plugin.
        Say, for instance, you can register a unique pluginID to use for a handshake message, so your separate plugin can pass its pluginID to the dialog plugin, which would listen to that specific pluginID.

        Other solution would be to make use of a "library plugin", providing some sort of API for the separate plugin to communicate with. Or even creating the separate plugin as such library plugin, which your dialog plugin would be calling for specific functionality.

        I seem to remember having tried some "library plugin" once in the past ... can't really remember much details, though.

        1 Reply Last reply Reply Quote 0
        • P
          PluginStudent
          last edited by

          You can create arbitrary plugin hooks using the MAXON API's interface system:

          https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_interfaces.html

          Especially look at registries:

          https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_registry_overview.html

          or published objects:

          https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_publishedobjects.html

          See these examples in maxonsdk.module:

          https://github.com/PluginCafe/cinema4d_cpp_sdk_extended/blob/master/plugins/maxonsdk.module/source/foundations/interfaces_declarations.h

          Alternatively, you can register arbitrary node plugins with RegisterNodePlugin().

          You could implement your functionality e.g. in the Message() method.

          https://developers.maxon.net/docs/cpp/2023_2/class_node_data.html

          1 Reply Last reply Reply Quote 0
          • WickedPW
            WickedP
            last edited by

            Thanks both of you. I'm still thinking this one through.

            @C4DS I hadn't thought of SpecialEventAdd, thanks for the suggestion. This had me looking into, and finding, GePluginMessage(). I'm wondering if I could call this in PluginStart(). This does seem to work. I could maybe avoid Cinema's Register system with this.

            @PluginStudent can I register a custom type using GeRegistryAdd()? Or does it have to be one of the listed types? E.g. can I register a type under my main plugin id?

            WP.

            wickedp.com

            1 Reply Last reply Reply Quote 0
            • F
              Filip
              last edited by

              @WickedP said in Custom register plugin:

              I have a dialog plugin with a graphical interface. I'd like to be able to register plugins for my plugin, so that I can build them separately if needed, or perhaps so others in the future may be able to.

              Hi WickedP!
              We are doing something similar in the 3delightForCinema4D renderer plugin. (source available here: https://gitlab.com/3Delight/3delight-for-cinema-4d/. We have a custom plugin system, separate from the normal c4d one, that allows 3rd party modules to add functionality to our plugin.

              This is handled via the "PluginMessage" function. When c4d has loaded, our plugin sends a special message to all other plugins, and passes along a pointer to a "pluginmanager" structure. Other plugins can then respond to this message, and register their plugins via the pluginmanager. You can see how this works in our source code. Some hints on where to look:

              The "API" for our plugin system consists of a few header files, describing the supported plugin types (called "hooks" and "translators"):

              https://gitlab.com/3Delight/3delight-for-cinema-4d/-/tree/master/3Delight/API/include

              Here is the main file of the module that manages plugin loading: https://gitlab.com/3Delight/3delight-for-cinema-4d/-/blob/master/3Delight/source/main.cpp

              The "PluginMessage" function in this file is where the message to load custom plugins is sent (in response to "C4DPL_STARTACTIVITY".

              Here is the main file of an example separate module that registers a number of plugins:
              https://gitlab.com/3Delight/3delight-for-cinema-4d/-/blob/master/3Delight Geometry/source/main.cpp

              I hope this description is somewhat clear. We have found it to be a really straightforward but powerful way of designing a custom plugin system for c4d! Let me know if you have any questions.

              Best regards
              /Filip

              1 Reply Last reply Reply Quote 1
              • kbarK
                kbar
                last edited by kbar

                You could also create a plugin that registered a C4DLibrary. Then your other plugins would make sure they are initialized after your plugin is by using the plugin startup priorities. Then those other plugins can safely call the library and register themselves with your main plugin via the library. Unfortunately I don't think there is much documentation on this though. This is how I handle my plugin manager, all of my other plugins register themselves with my plugin so that it can deal with licensing etc.. and only allow certain plugins to actually load at startup.

                https://www.gamelogicdesign.com
                https://www.plugins4d.com

                1 Reply Last reply Reply Quote 1
                • WickedPW
                  WickedP
                  last edited by WickedP

                  Thanks @Filip and @kbar, I've setup a simple message system that I'm experimenting with.

                  Just a question (for anyone) regarding the start up procedures for Cinema, will my plugin receive PluginMessage() messages if my main plugin is not registered yet? Asking to make sure I can receive a message from another plugin that Cinema might try to register before mine.

                  WP.

                  wickedp.com

                  1 Reply Last reply Reply Quote 0
                  • M
                    m_adam
                    last edited by m_adam

                    @WickedP yes you can assume it.

                    Cinema 4D first loads all dlls, then PluginMessage is forwarded to each dlls.

                    MAXON SDK Specialist

                    Development Blog, MAXON Registered Developer

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