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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python: Localized Plugin Name

    Cinema 4D SDK
    2024 python
    2
    5
    760
    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.
    • CJtheTigerC
      CJtheTiger
      last edited by

      I've read quite a few posts in the forum on how to use GeLoadString to get a localized string. I'm trying to do this for the name of an object generator plugin written in Python yet I'm always getting StrNotFound when calling GeLoadString during RegisterObjectPlugin.

      Let me show you what I got. Keep in mind that I excluded stuff that's irrelevant to this topic.

      This is my folder structure:

      • res
        • description
          • omyobject.h
          • omyobject.res
        • strings_en-US
          • description
            • omyobject.str
        • strings_de-DE
          • description
            • omyobject.str
        • c4d_symbols.h
      • Omyobject.pyp

      In res/description/omyobject.h is this:

      #ifndef _omyobject_H_
      #define _omyobject_H_
      
      enum
      {
          Omyobject                        = <mypluginid>
      }
      
      #endif
      

      ...where <mypluginid> is my plugin ID.

      In res/strings_**-**/description/omyobject.str is this:

      STRINGTABLE omyobject
      {
          Omyobject "My Object";
      }
      

      And finally in Omyobject.pyp I'm trying to register to plugin using this code:

          c4d.plugins.RegisterObjectPlugin(id=c4d.Omyobject,
                                           str=c4d.plugins.GeLoadString(c4d.Omyobject),
                                           g=Omyobject,
                                           description="omyobject",
                                           icon=bmp,
                                           info=c4d.OBJECT_GENERATOR|c4d.PLUGINFLAG_HIDEPLUGINMENU)
      

      str=c4d.plugins.GeLoadString(c4d.Omyobject) returns StrNotFound and I don't know why.

      What is the intended way to do this?

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

        Hi @CJtheTiger, you had almost correct 🙂

        The file are for the description aka the Object Manager and really specific to this part UI wise, if you want to store any string that you can use in any context you need to define in res/c4d_symbols.h.

        enum
        {
            Omyobject                        = <mypluginid>
        }
        

        And then you need to define your string in res/strings_-/c4d_strings.str.

        STRINGTABLE
        {
            Omyobject "My Object";
        }
        

        Then instead of using str=c4d.plugins.GeLoadString(c4d.Omyobject), you need to use the ID directly since c4d_symbols are not automatically parsed.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        CJtheTigerC 1 Reply Last reply Reply Quote 0
        • CJtheTigerC
          CJtheTiger @m_adam
          last edited by CJtheTiger

          Thank you for your response @m_adam.

          Unfortunately I'm still struggling even though I think I did what you suggested. I'm getting this error:

          Error reading resource file '...\res\strings_en-US\c4d_strings.str'
          Line 2

          The res\strings_en-US\c4d_strings.str has these contents:

          STRINGTABLE omyobject
          {
              Omyobject                    "My Object";
          }
          

          Removed link to my repo since it's no longer relevant and will be outdated soon.

          CJtheTigerC 1 Reply Last reply Reply Quote 0
          • CJtheTigerC
            CJtheTiger @CJtheTiger
            last edited by

            It seems like I found the working combination.

            The STRINGTABLE in res\strings_en-US\c4d_strings.str must not be named. In my previous response I pasted the contents which as you can see started with STRINGTABLE omyobject whereas it should simply be STRINGTABLE without a name.

            • I guess this str-file cannot contain named STRINGTABLEs. My first suspicion was that the error was caused by trying to define two STRINGTABLEs with the same name (since I had another STRINGTABLE with that name in the description folder) but even choosing another name in the c4d_strings.str resulted in the same error. Only when removing the name did I get rid of the error.

            I added the plugin ID to both the res\c4d_symbols.h and the res\description\omyobject.h as an enum member called Omyobject.

            • Having the ID in res\c4d_symbols.h allows for having a value outside of description resources (i.e. dialogs) which I required for the plugin name, as @m_adam already explained.
            • Having the ID in res\description\omyobject.h allows for description resources to access an accordingly named value in the STRINGTABLE in res\strings_xx-XX\description\omyobject.str. It also defines c4d.Omyobject which I'm now using in c4d.plugins.RegisterObjectPlugin to access the plugin name in res\strings_xx-XX\c4d_strings.str.
              • Note that this requires the plugin ID to be defined in two places (res\c4d_symbols.h and res\description\omyobject.h) which decreases maintainability.
              • Also note that I'm using the plugin ID from the description header to get a value from a non-description STRINGTABLE which sure enough does work but is probably not the cleanest solution.

            Does this sort of sound right? Is this the intended way?

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

              Hi you are right, I double checked and my c4d_string.str was like that, sorry I copy-pasted your in my reply without notifying it.

              // C4D-StringResource
              // Identifier	Text
              
              STRINGTABLE
              {
                PLuginName	"AAAAAA-ROUNDED Tube";
              }
              

              All the rest is correct in your sentences.
              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

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