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

    Python Tag Plugin Doesn't Work Properly With Resource Files

    Cinema 4D SDK
    python r23 c++
    2
    6
    975
    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.
    • beatgramB
      beatgram
      last edited by beatgram

      Hello guys,
      I'm a newbie to C4D python script / plugin development and please allow me to ask you guys some points.

      I tried to write a python tag plugin based on "py-look_at_camera_r13" example but I encountered the error like below when I attach the tag this plugin created.

      c4d_error.png

      I looked through this forum and I keep googling but I can't find the proper answer. I think the problem is related to description resource but I'm not familiar with these things. Python plugin development with resource files is pretty confusing...
      So please help me! Any help would be greatly appreciated.

      My code is below.

      text_plugin.pyp

      import os
      import c4d
      
      
      PLUGIN_ID = *******
      
      
      class TestPlugin(c4d.plugins.TagData):
          def Init(self, node):
              self.InitAttr(node, bool, c4d.TESTPLUGIN_ENABLE)
              node[c4d.TESTPLUGIN_ENABLE] = True
              pd = c4d.PriorityData()
              if pd is None:
                  raise MemoryError("Failed to create a priority data.")
              pd.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, True)
              node[c4d.EXPRESSION_PRIORITY] = pd
              return True
      
          def Execute(self, tag, doc, op, bt, priority, flags):
              return c4d.EXECUTIONRESULT_OK
      
      
      if __name__ == "__main__":
          register_check = c4d.plugins.RegisterTagPlugin(id = PLUGIN_ID, str = "Test Plugin", info = c4d.TAG_EXPRESSION | c4d.TAG_VISIBLE, g = TestPlugin, description = "Ttestplugin", icon = None)
          if register_check:
              print("Test Plugin by beatgram")
      
      
      

      c4d_symbols.h

      enum
      {
          // End of symbol definition
          _DUMMY_ELEMENT_
      };
      

      ttestplugin.h

      #ifndef _Ttestplugin_H_
      #define _Ttestplugin_H_
      
      enum
      {
          TESTPLUGIN_ENABLE = 1000
      }
      
      #endif
      

      ttestplugin.str

      STRINGTABLE Ttestplugin
      {
          Ttestplugin "Test Plugin";
          TESTPLUGIN_ENABLE "Enable";
      }
      

      ttestplugin.res

      CONTAINER Ttestplugin
      {
          NAME Ttestplugin;
          INCLUDE Texpression;
      
          GROUP ID_TAGPROPERTIES
      	{
      		BOOL TESTPLUGIN_ENABLE { ANIM ON; }
      	}
      }
      

      Plugin structure

      Test Plugin/
          test_plugin.pyp
          res/
              c4d_symbols.h
              description/
                  ttestplugin.h
                  ttestplugin.res
              strings_en-US/
                  ttestplugin.str
      

      ---------- User Information ----------

      Cinema 4D version: R23
      OS: Windows 10
      Language: Python

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        using your content is working perfectly fine here.
        Maybe you could zip the file and set it to us ?

        Does the python examples works on your system ?
        Did you copy/paste the py-look_at_camera directyory or did you create your own hierarchy on your drive ?

        Cheers,
        Manuel.

        MAXON SDK Specialist

        MAXON Registered Developer

        beatgramB 1 Reply Last reply Reply Quote 0
        • beatgramB
          beatgram @Manuel
          last edited by beatgram

          @m_magalhaes Thank you for checking on your end.
          That example code made a same error on my end and I created my own hierarchy on my drive.

          1 Reply Last reply Reply Quote 0
          • beatgramB
            beatgram
            last edited by beatgram

            I double checked my hierarchy / structure and finally I found my mistake!
            The structure below works well and I think it's correct one.

            Test Plugin/
                test_plugin.pyp
                res/
                    c4d_symbols.h
                    description/
                        ttestplugin.h
                        ttestplugin.res
                    strings_en-US/
                        description  -------------------- This folder needed! --------------------
                            ttestplugin.str
            
            1 Reply Last reply Reply Quote 1
            • ManuelM
              Manuel
              last edited by

              ho yes,

              sorry i created my hierarchy and added that directory without checking yours : /

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              beatgramB 1 Reply Last reply Reply Quote 0
              • beatgramB
                beatgram @Manuel
                last edited by

                @m_magalhaes Anyway thanks for the support, Manuel! I love this great community.

                1 Reply Last reply Reply Quote 0
                • DunhouD Dunhou referenced this topic on
                • First post
                  Last post