Storing Lists in BaseContainer [SOLVED]



  • On 16/11/2014 at 05:47, xxxxxxxx wrote:

    Basecontainers do not seem to be able to store Value, other than the supported Set*Type* Value.
    For instance trying to add a list:

      
    bc = c4d.BaseContainer()  
    liste = []  
    bc.SetData(1000, liste)  
    

    results in: TypeError: could not convert 'list'

    So how can this be done?
    And if not, how do you store a list or dictonary within an object or document?
    Sure, you could add all the list items one by one to a BaseContainer, but that does not seem like an appropriate way to do this?



  • On 16/11/2014 at 07:07, xxxxxxxx wrote:

    You can store it as an attribute of your Object/Tag/ShaderData class
    then write/read the data from/to file in Read() and Write(), and copy the
    data to another instance of your class in CopyTo().



  • On 16/11/2014 at 07:43, xxxxxxxx wrote:

    Ok, I think this is not what Im after, don´t want to use any external files, it should really get stored within the document.

    An example:

    I create a workflow command plugin, which needs to store and read lists of, for example, point IDs.
    This point index list I want to store within the doc´s bc.

    With a Sub Basecontainer in doc´s bc I could convert the list to a bc:

        bc = c4d.BaseContainer()  
      p_list = [11, 22, 33, 44]  
      for i, p in enumerate(p_list) :  
          bc.SetData(i, p)
    

    But really, this does seem like a very stupid  way, with lots of unnecessary computing and storing to convert list back and forth. Especially as lists get bigger.



  • On 17/11/2014 at 02:31, xxxxxxxx wrote:

    Hello,

    the functions Niklas was talking about are member functions of any NodeData based plugin. These functions allow you to handle member data when objects are saved with or loaded with the BaseDocument, so no other files than the scene file are involved.

    So the most elaborate way would be to create a NodeData based plugin that stores the data and handles the Read/Write/Copy process. What kind of plugin you would use depends on your workflow.

    A more simple idea would be to write all your data into a string, store that string and later use split() to rebuild the array.

    Best wishes,
    Sebastian



  • On 17/11/2014 at 06:02, xxxxxxxx wrote:

    Ah, have to do some research about that I guess.
    For now storing a number list as a string will do the job. Thanks, you two :-)


Log in to reply