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

    res file, formatting, line ending, or encoding ?

    Cinema 4D SDK
    windows c++ python
    3
    11
    343
    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.
    • M
      mogh
      last edited by

      Dear Developers,

      does anybody know what res files need to be (on Win 11, vs-Code)
      I was banging my head on the res files of my copied Tpylookatcamera (SDK Tag Plugin example R13) Python plugin and could not figure out why my copied version does not find the variable IDs but the "original" could.
      After several days editing my version I tried to edit the original Version (just a different name string for testing) an boom it also stopped working.
      So as far as i understand the res files seem to have a different encoding, line ending , ... or whatever vs-code does to the files ?

      Any idea or am I on the wrong track?
      I am learning to code on R20 but coding for R2025 so shame on me it might also be a R20 thing but its odd anyway.

      2025-02-15 19_45_11-.png
      Thank you
      cheers

      S 1 Reply Last reply Reply Quote 0
      • S
        spedler @mogh
        last edited by

        @mogh I think it's unlikely to be anything VS Code does. Millions of people use it and I've never heard of a problem caused by whatever line endings it adds.

        Much more likely is an error in the resource files. Earlier versions of Cinema were incredibly sensitive to mistakes in the resource and the stock response is to show that message. Misleadingly, it says the error is in the .res file but it could actually be in the matching .h. or .str files.

        The most common errors I find are:

        • the name of an element in the .res file doesn't match with any in the .h or.str files, so if you change one you need to change the others
        • there's a formatting error in the .res file - a missed semi-colon, comma, or mismatching parentheses or curly braces
        • the 'CONTAINER' or 'NAME' strings at the start of the .res file don't match the 'STRINGTABLE' line in the .str file or the line which follows it

        There are probably other causes but these are the commonest ones (IMO). If you altered the name of an element .res file of your plugin did you change the .h and .str files to match? And if you did, did you alter the Python source code to use the new name?

        Steve

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

          Thank you for the reply,

          • I learned that all the "names / files" have to be the same ... Filename, NAME, CONTAINER, STRINGTABLE
          • The semi-colon is a thing I tried in several configs, and as soon as you touch the files you need them but the strange thing is that the original SDK example has non! The error above is from a missing semicolon. (its gone now with the semicolon after the curly brackets)
          • I changed the ID name and replaced the name in all corresponding files ... still the new variable name is not "found" by c4d.

          Just as a sanity check I also tried removing a character
          PYLOOKATCAMERA_PITCH_A -> error
          PYLOOKATCAMERA_PITCH -> works
          PYLOOKATCAMERA_PITC -> error

          Res, Str, H Files

          enum
          {
              // End of symbol definition
              _DUMMY_ELEMENT_
          };
          
          CONTAINER Tpylookatcamera
          {
          	NAME Tpylookatcamera;
              INCLUDE Texpression;
              
              GROUP ID_TAGPROPERTIES
          	{
          		BOOL PYLOOKATCAMERA_PITCH_A { };
          	}
          }
          
          STRINGTABLE Tpylookatcamera
          {
          	Tpylookatcamera         "Py - Look At Camera";
              PYLOOKATCAMERA_PITCH_A    "Change Pitch Rotation";
          }
          
          #ifndef _Tpylookatcamera_H_
          #define _Tpylookatcamera_H_
          
              enum
              {
                  PYLOOKATCAMERA_PITCH_A     = 1000
              };
          
          #endif
          

          snippet:

          self.InitAttr(node, bool, c4d.PYLOOKATCAMERA_PITCH_A)
          node[c4d.PYLOOKATCAMERA_PITCH_A] = True
          

          Error:

          AttributeError: 'module' object has no attribute 'PYLOOKATCAMERA_PITCH_A'
          
          S 1 Reply Last reply Reply Quote 0
          • S
            spedler @mogh
            last edited by spedler

            @mogh Ah, this is the old symbol cache bug/feature. I'd forgotten about that. With Cinema not running, go into the prefs folder - you can get the location by running Cinema, opening the Preferences dialog, and click 'Open Preferences Folder...'.

            In that folder you'll see a file called 'symbolcache', probably with today's date. Delete that file, then run/restart Cinema and all should now work with your revised resource files.

            AFAIK this was only a problem with Python plugins, not C++. I've tested this in R19, not R20, but my guess is that it's the same in R20.

            (Edit - yes, same in R20.)

            Steve

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

              @spedler Thank you for your time you put into this,

              I managed to get the "original" running with a different ID Name after deleting (.../prefs/symbolcache )

              My own copy with Filename, NAME, CONTAINER, STRINGTABLE, ID Name still bugs out.

              I am probably blind 😕
              mogh

              enum 
              {    
                  // End of symbol definition
                  _DUMMY_ELEMENT_
              };
              
              #ifndef _curvaturetools_H_
              #define _curvaturetools_H_
              
                  enum
                  {
                      CTBOOL      = 2001
                  };
              
              #endif
              
              CONTAINER curvaturetools
              {
              	NAME curvaturetools;
                  INCLUDE Texpression;
                  
                  GROUP ID_TAGPROPERTIES
              	{
              		BOOL CTBOOL { };
              	}
              }
              
              STRINGTABLE curvaturetools
              {
              	curvaturetools     "Py - Look At Camera";
                  CTBOOL       "Change Pitch Rotation";
              }
              

              2025-02-16 16_22_33-c4d_symbols.h - plugins - Visual Studio Code.png

              S 1 Reply Last reply Reply Quote 0
              • S
                spedler @mogh
                last edited by

                @mogh If you are using the same code but just different resource files, did you remember to change the resource name in the RegisterTagPlugin() function?

                Steve

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

                  No the SDK Example has no
                  res (Optional[c4d.plugins.GeResource]) – The optional resource.
                  for RegisterTagPlugin ...

                      c4d.plugins.RegisterTagPlugin(id=PLUGIN_ID,
                                                    str="Py - LookAtCamera",
                                                    info=c4d.TAG_EXPRESSION | c4d.TAG_VISIBLE,
                                                    g=LookAtCamera,
                                                    description="Tpylookatcamera",
                                                    icon=bmp)
                  
                  1 Reply Last reply Reply Quote 0
                  • S
                    spedler
                    last edited by

                    What I meant was, if your resource files are now named curvaturetools.res/h/str then RegisterTagPlugin() must contain the ‘description’ parameter to be “curvaturetools” not “Tpylookatcamera”.

                    Steve

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

                      Thats it !
                      Thank you @spedler

                      1 Reply Last reply Reply Quote 0
                      • S
                        spedler
                        last edited by

                        Excellent. Glad you got it working okay.

                        Steve

                        1 Reply Last reply Reply Quote 0
                        • ferdinandF
                          ferdinand
                          last edited by

                          Thanks for helping out @spedler!

                          MAXON SDK Specialist
                          developers.maxon.net

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