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

    Could not initialize global resource

    PYTHON Development
    0
    5
    919
    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 18/06/2018 at 08:35, xxxxxxxx wrote:

      Hi folks,
      Recently, I tried to create my first Python plug-in, and I was troubled by a problem for a long time.

      Console:  RuntimeError: Could not initialize global resource for the plugin.

      I search a lot in the SDK document and forum, but I still don't know how to solve it. I hope can get your help. Here's my test code:

      (test.pyp)
      _____
      import c4d
      import sys
      import os
      from c4d import plugins,bitmaps
      PLUGIN_ID = 1000001
      OBJECTGROUP = 1001
      OBJECT = 1002
      MAP = 1003
      class test(plugins.ObjectData) :
      def __init__(self) :
      self.SetOptimizeCache(True)
      def ModifyObject(self, mod, doc, op, op_mg, mod_mg, lod, flags, thread) :
      op.SetPoint(0,c4d.Vector())
      op.Message(c4d.MSG_UPDATE)
      return True
      if __name__ == "__main__":
      bmp = bitmaps.BaseBitmap()
          dir, file = os.path.split(__file__) 
      bitmapfile = os.path.join(dir, "res", "Icon.tif")
      result = bmp.InitWith(bitmapfile)
      plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="test",g=test,description="test",icon=bmp,info=c4d.OBJECT_MODIFIER)
      ___
      (test.h)
      __
      #ifndef _Oatom_H_
      #define _Oatom_H_
      enum
      {
          OBJECTGROUP = 1001,
          OBJECT = 1002,
          MAP = 1003,
      };
      #endif
      __
      (test.res)
      __
      CONTAINER test
      {
      NAME test;
      INCLUDE Obase;
      GROUP OBJECTGROUP
      {
          LINK OBJECT {}
          LINK MAP {}
      }
      }
      __
      (test.str)
      __
      STRINGTABLE test
      {
      OBJECTGROUP "List";
      OBJECT "obj"
      MAP "map";
      }

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

        On 19/06/2018 at 02:21, xxxxxxxx wrote:

        Hi,

        The resource for the plugin can't be initialized because there's an error in test.str : a semicolon ';' is missing at the end of the line OBJECT "obj".

        It looks like you've copied the resource for C++ SDK Oatom example.
        It's better to copy the resource for a Python SDK example, for instance object plugin Py-RoundedTube.
        Use this as a base to define resources: macro #def in .h, naming for parameters, resource tree structure etc.

        Note Python plugins resource need c4d_symbols.h present in res folder.

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

          On 20/06/2018 at 08:05, xxxxxxxx wrote:

          Thank you for your help, Yannick Puech!

          My first test plugin  run  successfully!

          I made a stupid mistake a lot, such as forgetting to add a semicolon ";" and I forgot to add "s" folder of strings. It is these wrong to let me crazy for a long time. Next time I encounter a problem, I will check these low-level mistakes first.

          I also want to ask a question again, why is the c4d_symbols.h file necessary? There seems to be nothing in it. What role does he have? I don't seem to find his introduction in the document. This also confuses me.

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

            On 21/06/2018 at 01:21, xxxxxxxx wrote:

            The c4d_symbols.h has to be there even if it's empty. It's mandatory for plugins that use description resources.

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

              On 21/06/2018 at 07:40, xxxxxxxx wrote:

              Yeah, I get it! Thank you for your patient answer, Yannick Puech!

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