Saving data in document



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/07/2005 at 15:54, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.x-9.x 
    Platform:   Windows  ; Mac  ;  Mac OSX  ; 
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    I need to save data in the document in order to have access to it each time I open the document in the future.
    How can I save data with the document (if possible) in a way that it doesn't ruin the document if it is opened in a Cinema4D that doesn't have my plug-in?
    And how can I check if the document already has that data?
    Thank you VERY MUCH for any answer.

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/07/2005 at 18:36, xxxxxxxx wrote:

    UserData seems like the only option here. The standard approach is to store the data via your plugin (plugin object, tag, material, etc.) to the document. But to do it in a way that doesn't require the plugin be available would only allow UserData as an option since there is no other control for saving c4d documents.

    I'd be interested if there was another way to do it.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/07/2005 at 01:56, xxxxxxxx wrote:

    Thank you for the answer, Robert.
    In my case, it will be a menu plug-in. I can always create a Null and store the required info as additional data in the Null container. But that is not as elegant :(
    So, we both still would like to get an answer, right? ;)

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2005 at 06:10, xxxxxxxx wrote:

    The document has a Base Container, right?
    Can't we add data to the document Base Container, provided that the IDs are out of the range of the pre-coded IDs?
    Has anyone done it before?

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2005 at 08:45, xxxxxxxx wrote:

    Yes.

    Okay, the data will be stored in the document and most likely saved with it. If a user has your plugin, access to the data is available. If not, the data just sits there harmlessly - one hopes ;). But I'm not sure what happens when the document with the extra data is saved without the plugin. Does the data persist?

    I'd do some experiments to verify that all of this is possible, then you are on your way!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2005 at 10:38, xxxxxxxx wrote:

    There is something else in regards to the IDs themselves. Deciding on valid and off-limits IDs may be something of a minefield. It may be the case that the IDs for the data in the BaseDocument, in order to remain unique, must be associated with unique IDs furnished by PluginCafe.

    You have no control on whether or not your IDs will become invalid by their use by Maxon or other plugins otherwise.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/07/2005 at 02:38, xxxxxxxx wrote:

    Thank you for your time and knowledge, Robert.
    Lets say I have been providede with ID 123456789 for the plug-in. Would I be able to use the same number for the added ID to the document Base Container?
    Oh, and what I want to add is a list of objects (actually, several lists of objects). Can I store an array in a single ID? Or do I need an ID for each element?!?

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/07/2005 at 07:32, xxxxxxxx wrote:

    It is allowed to store plugin data in the documents BaseContainer, you must use a plugin ID and then store your data in a subcontainer or just use plugin IDs for each element (but a subcontainer is better if storing many values otherwise you are eating up lots of plugin IDs!).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/07/2005 at 07:43, xxxxxxxx wrote:

    Thank you for your answer, David.
    How can I create such a subcontainer?

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/07/2005 at 08:07, xxxxxxxx wrote:

    Sorry, no idea about COFFEE. Its just a BaseContainer, in C++ its just SetContainer() and you pass in your BaseContainer with your settings.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/07/2005 at 09:25, xxxxxxxx wrote:

    BaseContainers can't store arrays or lists, only single elements. You could try creating your own CustomDataType. Or, set one of the BaseContainer elements to the number of objects and add each element using IDs starting from a predetermined value. For example:

    ID_MYCONTAINER_ID /Plugin ID/
    ID_MYCONTAINER_COUNT 999   // LONG
    ID_MYCONTAINER_START 1000 // First element ID

    Then you'll loop inside your plugin (when available) to get the elements (after getting your subcontainer 'bc') :

      
    LONG count = bc->GetData(ID_MYCONTAINER_COUNT);  
    // Allocate a storage array if needed Here  
    for(LONG x = 0; x < count; x++)  
    {  
         array[x] = bc->GetData(ID_MYCONTAINER_START+i)  
    }  
    

    And David has it correct. If you store in the top level container, you'll need unique IDs for each element. So store your BaseContainer in the top level BaseContainer of the BaseDocument and you only need a unique ID for your BaseContainer. The data that you store in your BaseContainer can have any IDs that you want.

    It looks like you need to use SetData(id, data) to add the subcontainer to the BaseContainer.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/07/2005 at 01:29, xxxxxxxx wrote:

    Storing a sub-container in C.O.F.F.E.E. is as simple as storing anything else. Just create a subbc = new(BaseContainer) and then use bc->SetData(ID, subbc) to set and bc->GetContainer() to retrieve it.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/07/2005 at 07:44, xxxxxxxx wrote:

    We're using the BaseDocuments container to store data to the project, it is safe as long you write the data to IDs of the Plugin-Area, we use the IDs of our plugins to store data.
    I think a customdatatype will not help you much, you will run into the same problem. If you want to store a list, the most simple approach is to make a container for it, define a LONG in which you store the number of entries of the list and a ID where the first list element starts in the container. Its easy to make even more complicated structures.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/07/2005 at 08:42, xxxxxxxx wrote:

    Isn't that exactly what I detailed above? ;)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/07/2005 at 10:04, xxxxxxxx wrote:

    I just wanted to add that all you need to do is to create a subcontainer and store all your values within this one. Additionally use the first value to store the value count. Then you can simply store the subcontainer in the documents container with a plugin id from plugincafe...wait, i fell like repeating. 8-D



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/08/2005 at 13:30, xxxxxxxx wrote:

    Is there anybody with a codesnippet that simply works?

    Counting the "you only have to" and "its that simple" in this thread is impressing.
    Only within the sdk examples set-or getcontainer is not included and i am confused by the sdk-documentation:

    "SetContainer(LONG id, const BaseContainer& s)
    Sets the sub-container with the specified ID to s, or inserts it if it didnt exist."

    Tried this but it did not work as expected.
    any help?

    Peter


Log in to reply