Dump/Restore UserDataContainer



  • Hi,

    Is it possible to dump (and restore) a complete UserDataContainer?
    ie. save the whole information into a definition in a python source that can be then used to auto generate identical UserDataContainers?

    I'm talking about the data types and structure (groups etc), not the value content.

    best, index



  • Hi,

    I am not quite sure what you would consider possible in this context.

    1. You can of course just create some Python code that hardcodes the desired structure of the container.
    2. You could obviously also automate this, by lets say taking in some template container and then saving the data structure to a JSON file. But this approach has two problems: You are not able to identify the data type of all container values in Python, because some types have not been ported. And for the ones you can identify you are sometimes not able to create some null value out of nothing when rebuilding the container. This both only concerns some more fringe data types like function pointers or memory dumps and of course also limits your possibilities in 1.
    3. The best solution is probably to write the template container to a c4d.storage.Hyperfile and then read this file back. This will obviously also serialise and deserialise the values of the container, not only its structure. But again, it is not always possible to populate all data types of some random container structure in Python anyways.

    Cheers,
    zipit



  • thanks zipit,

    using Hyperfile looks very promising,
    the Userdata Container seems to be a list containing tuples and BaseContainers,
    I will try to store that into a file and report back If it works :)

    index


Log in to reply