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

    Storage issues with plugin settings

    Cinema 4D SDK
    2023 python windows
    2
    3
    431
    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.
    • N
      Neekoe
      last edited by

      Hello everyone, I have encountered a problem. When I select a folder through the button, it will update the. c4d type files in the folder to TREELIST, including the path in an EDITNEXT that I set. However, after I restart the plugin or C4D, these contents are missing. Do you have any methods or documentation to refer to? be deeply grateful
      Snipaste_2025-02-19_00-15-10.png
      Snipaste_2025-02-19_00-16-40.png

      1 Reply Last reply Reply Quote 0
      • DunhouD
        Dunhou
        last edited by

        Hi @Neekoe ,

        There are many ways to save data, like c4d.storage.HyperFile or json-like stuff, or you can use WorldContainer, I like to use json for my plugins, but for more "c4d-like", you can use WorldContainer.

        Cheers~
        DunHou

        import c4d
        
        YOUR_UID: int = 123456789
        
        # Setting id, better to use a unique id, but not necessary
        SETTING1: int = 1000
        SETTING2: int = 1001
        
        
        def main() -> None:
            # Create a new BaseContainer for storing the plugin data
            bcWorld: c4d.BaseContainer = c4d.GetWorldContainerInstance()
            bcPlug: c4d.BaseContainer = c4d.BaseContainer()
            bcPlug.SetBool(SETTING1, True)
            bcPlug.SetInt32(SETTING2, 10)
            bcWorld.SetContainer(YOUR_UID, bcPlug)
        
            # Get the BaseContainer from the world container
            bcPlug: c4d.BaseContainer = bcWorld.GetContainerInstance(YOUR_UID)
            print(bcPlug.GetBool(SETTING1))
            print(bcPlug[SETTING2])
        
        if __name__=='__main__':
            main()
        

        https://boghma.com
        https://github.com/DunHouGo

        N 1 Reply Last reply Reply Quote 0
        • N
          Neekoe @Dunhou
          last edited by

          Thank you for @Dunhou answer. It was ultimately completed in JSON format

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