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

    ToolData InitDefaultSettings

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 433 Views
    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 Offline
      Helper
      last edited by

      On 14/11/2016 at 08:37, xxxxxxxx wrote:

      Hi again,

      Working on a plugin I assumed that InitDefaultSettings would be called each time the python plugins are reloaded.
      For now, the method is only called the first time the plugin is activated after starting Cinema4D, and only the first time you perform  "reload python plugins" after Cinema4D has started.
      Any subsequent "reload python plugins" just simply doesn't call the InitDefaultSettings.

      Is this as intended?

      Below is a simplified plugin which shows this behaviour.

        
      import c4d  
      import os  
        
      from c4d import gui, plugins, bitmaps, utils  
        
      PLUGIN_ID = 1031001 # dummy ID  
        
        
      class Testing(plugins.ToolData) :  
        
        def __init__(self) :  
            print "__init__"  
            return  
              
        def InitDefaultSettings(self, doc, data) :  
            print "InitDefaultSettings"  
            return  
              
        def InitTool(self, doc, data, bt) :  
            print "InitTool"  
            return True  
              
        def FreeTool(self, doc, data) :  
            print "FreeTool"  
            return  
              
        def Message(self, doc, data, type, t_data) :  
            return True  
        
      # =============== Main =============  
              
      def PluginMain() :  
        try:  
            bmp = bitmaps.BaseBitmap()  
            dir, file = os.path.split(__file__)  
            fn = os.path.join(dir, "res", "Testing.tif")  
            bmp.InitWith(fn)  
            plugins.RegisterToolPlugin(id=PLUGIN_ID, str="Testing",  
                                        info=0,  
                                        icon=bmp,   
                                        help="Testing",  
                                        dat=Testing())  
        except TypeError:  
            # when performing a 'reload plugin' without the plugin being registered to the system yet  
            # -> user should restart Cinema 4D  
            print "Unable to load plugin (Testing)"  
              
      if __name__ == "__main__":  
        PluginMain()  
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 16/11/2016 at 07:03, xxxxxxxx wrote:

        Hi,

        sorry for being quiet here. I'm currently waiting for an answer from our development to give a more profound answer.

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

          On 16/11/2016 at 12:22, xxxxxxxx wrote:

          Thanks for the message, Andreas.
          Looking forward to such reply.

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

            On 22/12/2016 at 01:51, xxxxxxxx wrote:

            Any update on this?

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

              On 23/12/2016 at 09:06, xxxxxxxx wrote:

              Hi,

              I confirm ToolData.InitDefaultSettings() is only called once for each ToolData and execution of Cinema 4D.
              So the default settings for a ToolData are initialized once and this is the normal behavior.

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