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

    Accessing resource in ObjectData

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 264 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 18/10/2010 at 04:29, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R12 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :       PYTHON  ;

      ---------
      Hello,

      I'm trying to write an Object Plugin in Python and I have a problem. Here a sample code :

      Test.py :

        
      import os   
      import c4d   
      from c4d import plugins, documents, utils   
      # be sure to use a unique ID obtained from www.plugincafe.com   
      PLUGIN_ID = 1000006   
                
      class Test(c4d.plugins.ObjectData) :   
                
          def GetVirtualObjects(self, op, hh) :   
              print c4d.BAR   
              print op.GetDataInstance().GetBool(1000)   
              return c4d.BaseObject(c4d.Ocube)   
        
      if __name__ == "__main__":   
          bmp = c4d.bitmaps.BaseBitmap()   
          dir, file = os.path.split(__file__)   
          fn = os.path.join(dir, "res", "icon.tif")   
          bmp.InitWith(fn)   
          c4d.plugins.RegisterObjectPlugin(id = PLUGIN_ID, str = "Test", g = Test,   
                                          description = "foo", info = c4d.OBJECT_GENERATOR | c4d.OBJECT_INPUT, icon = bmp)   
      

      foo.h

        
      #ifndef _FOO_H_   
      #define _FOO_H_   
        
      enum   
      {   
           BAR                                   = 1000, //     BOOL   
              
           DUMMY_   
      };   
        
      #endif   
      

      foo.res

        
      CONTAINER foo   
      {   
           NAME foo;   
           INCLUDE Obase;   
        
           GROUP ID_OBJECTPROPERTIES   
           {   
              BOOL BAR {};   
           }   
      }   
      

      I'm trying to get the BAR boolean value.
      With the GetDataInstance().GetBool that works, but the line "print c4d.BAR" generate this error :
      AttributeError: 'module' object has no attribute 'BAR'

      I don't understand why, in a plugin tag i access resource with the same way and it worked.

      Here the project : http://www.xsyann.com/plugincafe/Test.zip

      Some help is welcome... 🙂

      Thank you,
      Greetings,

      Yann.

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 18/10/2010 at 07:05, xxxxxxxx wrote:

        Hi Yann,

        C4D adds the resources of a registered plugin to the c4d main module and writes them to "userfolder/prefs/coffeesymbolcache". If you change your resource files, just remove this file and restart C4D. I hope this helps.

        Cheers, Sebastian

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 18/10/2010 at 07:19, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          I hope this helps.

          This solves the problem.
          Thank you very much Sebastian.
          Greetings,
          Yann

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