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

    Best practice for BaseContainer Types

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 402 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 16/02/2018 at 01:11, xxxxxxxx wrote:

      Hi Everyone,

      Im currently writing a plugin that stores and retrieves takes data.

      Im planning to store 5 separate lists of strings in a sub-basecontainer (to keep the data with the file)

      (following along from this post -  https://developers.maxon.net/forum/topic/8019/10416_saving-custom-attributes-with-a-scene-file)

      So, as per this:

      subC = c4d.BaseContainer() 
      subC.SetString(NAME_IDS _, NAME_LIST _)

      __ What do i need to set the the subC type to, so i can store lists?

      And if i want to store 5 separate lists of strings, is there any conflict i need to be aware of? _
      "Once you've set a container value using one type you must neither try to access it using another type, nor overwrite it with a value of another type! Using the wrong access will not crash, but it is illegal."

      _ I am fully aware of the above from the documentation, hence asking for advice on best practice.

      Any and all information would be much appreciated!

      Thanks,

      Cerac __

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

        On 16/02/2018 at 03:45, xxxxxxxx wrote:

        You will need to provide your own list implementation.
        I do this by creating a subcontainer, storing the number of entries at index 0, then storing the different entries at following indeces (or in a separate subcontainer)

        Something like

          
        BaseContainer bcList;  
        bcList.SetInt32(0, count);  
        BaseContainer bcData;  
        for (Int32 i = 0; i < count; ++i)  
          bcData.SetString(name_list[i]);  
        bcList.SetContainer(1, bcData);  
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post