Storing data in the Doc's BaseContainer? [SOLVED]



  • On 03/06/2015 at 16:23, xxxxxxxx wrote:

    Hi,

    I'm looking to save the state of a toggle button with the document. Doing some testing, it seems like I can do that with:

      
    doc[PLUGIN_ID] = True   
    

    Is it safe for me to store my data directly in the document's container so long as I'm using a unique plugin ID? If not, where would you recommend storing this sort of information for Python Command Plugins?
    Thanks,

    Donovan



  • On 03/06/2015 at 16:33, xxxxxxxx wrote:

    Okay, seems like the issue is addressed in this thread. In short: it appears that storing this info in the doc's container is totally legit.

    That said, it's apparently best practice to use a sub container, and only for small amounts of data. Something more like:

      
    toggle_bc = c4d.BaseContainer()   
    toggle_bc[TOGGLE_ID] = True   
    doc[PLUGIN_ID] = toggle_bc   
    

    Where PLUGIN_ID is a unique ID from PluginCafe, and TOGGLE_ID is used to store the info in the sub-container, just in case the plugin will ever need to store additional data.


Log in to reply