On 02/08/2018 at 06:11, xxxxxxxx wrote:
Hi Tuft, first of all, welcome in the PluginCafe forum!
BaseDocument, like Objects, tag and pretty much everything a user can find in C4D inherit from BaseList2D, as you already found get a BaseContainer.
A BaseContainer is a kind of array (or a dictionary in python), where data are stored according to a given ID.
The benefice of BaseContainer, is all data stored within are part of the BaseList2D (so the object, tag, document) and they are automatically saved, read when you save/load a file.
For more information, you can read the C++ manual about BaseContainer.
Now regarding your question, you can easily add data to the BaseContainer of the document.
Since you don't want to override your parameter or other plugins to override your entry, you should get a unique ID here.
Now you can do something like that
YourUniqueId = 1000001
# Get an Instance of the BaseContainer (that mean all changes are directly made in the document)
bc = doc.GetDataInstance()
bc[YourUniqueId] = 10 # Set the value
print bc[YourUniqueId] # Read the value
If you have more than one value it's recommended to create a BaseContainer with all your data and then store this BaseCcontainer within the BaseContainer of the document with your unique ID.
The BaseContainer principle applies to everything, but if you want to attach data to a specific object, you can also create a Tag, depending on your need, but please let me know if you have any questions!
Cheers,
Maxime