Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Dump/Restore UserDataContainer

    Cinema 4D SDK
    2
    4
    506
    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.
    • indexofrefractionI
      indexofrefraction
      last edited by

      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

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @indexofrefraction
        last edited by ferdinand

        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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • indexofrefractionI
          indexofrefraction
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • indexofrefractionI
            indexofrefraction
            last edited by indexofrefraction

            i finally succeeded in saving a BaseList2D userdata description (not the values)
            then loading and re-applying / cloning the full definition to a different BaseList2D,
            and finally copy over the values from the source to the target BaseList2D

            here is a similar topic for saving / loading the values (not the description) here:
            https://developers.maxon.net/forum/topic/11960/advice-for-saving-user-data/8
            I made a comment there about copying the userdata values

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