Storage issues with plugin settings
-
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
-
Hi @Neekoe ,
There are many ways to save data, like
c4d.storage.HyperFile
orjson-like stuff
, or you can useWorldContainer
, I like to use json for my plugins, but for more "c4d-like", you can use WorldContainer.Cheers~
DunHouimport 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()
-
Thank you for @Dunhou answer. It was ultimately completed in JSON format