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
    • Login

    Run Plugin Last

    Cinema 4D SDK
    python r19
    2
    3
    766
    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.
    • A
      AndreAnjos
      last edited by r_gigante

      Hi guys,

      I'm drafting a tool that will inform the user with any plugins/scripts updates and that will point to the relevant wiki page for more information.
      0_1548341751824_39c52696-198c-467b-a2b0-6698562b1f30-image.png

      I have a few questions that hopefully you can help me address.

      1. Is it possible to run the plugin last or after everything else is loaded?
      2. Because I'm dynamically creating the IDs for the buttons on the left, what would be the best approach to retrieve the correct id to link it it to the correct command, once the button is pressed?
        Perhaps collect the data in the plugin's BaseContainer()?

        Found the solution here: https://developers.maxon.net/forum/topic/6375/6817_nth-button-press/2
        I should give sequential IDs to make it easier to collect them. I've then created a BaseContainer() under the plugin with each id and values. The values were separated by commas for me to split later. Perhaps this is bit too complex?😅

      The next steps would be to change the dialog to a treeview, which will look a lot cleaner.

      Thank you in advance! ☺

      Andre

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

        Hi @AndreAnjos ,

        Cinema 4D offers multiple Messages that can be caught in the PluginMessage method of your plugin.

        You can find relevant messages ID in the Plugin Functions Manual C++ manuals in the Start section.

        Note all these Messages are also sent to Python plugin. See c4dpl

        Here a full example

        import c4d
        
        PLUGIN_ID = 1000001
        
        class MyDialog(c4d.gui.GeDialog):
        
            def CreateLayout(self):
                self.SetTitle("My Python Dialog")
        
                return True
        
        def PluginMessage(id, data):
            print "Pluginmessage"
            if id==c4d.C4DPL_PROGRAM_STARTED:
                c4d.CallCommand(PLUGIN_ID)
        
        class CommandDataPlugin(c4d.plugins.CommandData):
            dialog = None
        
            def Execute(self, doc):
                if self.dialog is None:
                   self.dialog = MyDialog()
        
                return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaulth=400, defaultw=400)
        
            def RestoreLayout(self, sec_ref):
                if self.dialog is None:
                   self.dialog = MyDialog()
        
                return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
        
        if __name__ == "__main__":
            c4d.plugins.RegisterCommandPlugin(
                PLUGIN_ID,
                "CommandDataPlugin",
                0,
                None,
                None,
                CommandDataPlugin())
        
        1. Yes, this is the correct way for doing it. Maybe you can simplify this by not using a BaseContainer but simply looping over and using a BaseID + the ID of the item in the loop.
          Another way could be to implement SubDialog, A good example can be found at https://labs.maxon.net/?p=3235 where each COFFEE element is a SubDialog.

        But in any case, this will not work for a TreeView.

        If you have any questions please let me now.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        A 1 Reply Last reply Reply Quote 3
        • A
          AndreAnjos @m_adam
          last edited by

          @m_adam
          Hi Maxime,

          It works like a treat!
          I've ended up changing the UI to a treeView and it's still working great.
          Thank you very much! ☺

          Andre

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