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

    SetWorldContainer bug

    Scheduled Pinned Locked Moved Bugs
    4 Posts 0 Posters 998 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

      On 30/07/2017 at 03:22, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   18.057 
      Platform:   Windows  ;   
      Language(s) :       PYTHON  ;

      ---------
      Method c4d.SetWorldContainer() isn't working in Cinema4D R18.057. 
      The container is not updated and the data remains the same.
      With C4D R17 this code works fine.
      Perhaps this is somehow connected with this bug 

      import c4d
        
      PLUGINID = 1234588880
        
      def main() :
        
          wbc = c4d.GetWorldContainer()
          if not wbc[PLUGINID]:
              bc = c4d.BaseContainer()
              wbc[PLUGINID] = bc
        
          bc = wbc.GetContainer(PLUGINID)
          print bc[1] #check stored value, on next launch the scipt it must be 1.0, but still None
          bc.SetFloat(1,1.0) 
          wbc.SetContainer(PLUGINID,bc)
          c4d.SetWorldContainer(wbc)
          print bc[1]
        
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 31/07/2017 at 03:20, xxxxxxxx wrote:

        Hi,

        Yes the issue here is related to the other getting containers with [] operator.
        The condition if not wbc[PLUGINID] is always entered (returns None) so the container is then always reset.
        Use wbc.GetContainer(PLUGINID) instead.

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

          On 01/08/2017 at 03:59, xxxxxxxx wrote:

          ok, im trying to find solution. And now other question about BaseContainer:
          this code works fine with R17 and not with R18.057.
          Whats wrong with this example?

          import c4d
          from c4d import gui
          #Welcome to the world of Python
            
          PLUGIN_ID = 10000025
            
          def main() :
              data = op.GetDataInstance()
              bc = data.GetContainer(PLUGIN_ID)
              color_bc = bc.GetData(1)
              
              if not color_bc:
                  color_bc = c4d.BaseContainer()
                  color_bc.SetVector(0,c4d.Vector(0,0,0)) 
            
              else:
                  i = len(color_bc)
                  color_bc.SetVector(i,c4d.Vector(i,i,i))
              
              bc.SetContainer(1,color_bc) 
              data.SetContainer(PLUGIN_ID,bc)
              op.SetData(data)
              
              bc = data.GetContainerInstance(PLUGIN_ID)
              color_bc = bc.GetData(1)
              
              for i,v in color_bc: 
                  print i,v
            
            
          if __name__=='__main__':
              main() 
          

          In all my plug-ins and scripts, I use this method of storing information in an object, document, or program settings containers. But now I just have no idea how this should work. After the release update 18.057 I began to receive a tons of bug reports from users!

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

            On 01/08/2017 at 08:15, xxxxxxxx wrote:

            In R18.057 GetData() has the same issue as the get [] operator. Use GetContainer() or GetContainerInstance() instead.
            In your script the call to op.SetData(data) is useless because you are already working on the data instance. In the beginning of the script data = op.GetDataInstance().

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