PDA

View Full Version : Include custom data in a basecontainer


Myel
02-28-2006, 09:40 AM
Hi!

I need to save some points arrays in my Plugin. Thus, I have used the CustomDataType functions and it works fine : these arrays are saved and loaded correctly. Now, I try to add Undo actions. But I can not use the function BaseContainer::AddUndo(LONG type, void *data) when data points to a element of a CustomDataType because Cinema4D crashes in that case.
Apparently, the reason is that I can use AddUndo() in this way : the data must be included in a container of the document.
Therefore, my question is :

How can I put a CustomDataType in a BaseContainer?
That is not clear in the documentation. Can anybody eventually have a little code?

Thanks in advance,

Myel

Per-Anders
02-28-2006, 09:00 PM
You use SetData, then set it just as you do for any other customdatatype (read up on cinema's universal datatype GeData).

If you're making an object/scenehook etc you shouldn't have any problems with your custom datatype and undo's if you use the CopyTo function correctly, and then you dont' need to store it in the basecontainer.

Myel
03-02-2006, 06:05 PM
Thanks for your reply.
In fact, in the Init function, I wrote the following code:

Bool MyTag::Init(GeListNode *node)
{
BaseContainer *data = tag->GetDataInstance();
GeData Ged = GeData(ID_MCD, M_Dt);
data->SetData(ID_MCD, Ged);
tag->SetData(*data);
}
where ID_MCD is the ID for MyType (my CustomDataType), M_Dt is my data of type MyType.

Where do I need to write the same code? Each time I modify my data M_Dt? (by example in the function Message(GeListNode *node, LONG type, void *data) when I modify the contents of M_Dt according to the actions of the user?

I have two other questions:
- Is it enough to load and save my data? Previously, I used the functions CopyTo(NodeData* dest, GeListNode* snode , GeListNode* dnode, long flags, AliasTrans* trn), Read(GeListNode *node, HyperFile *hf, LONG level) and Write(GeListNode *node, HyperFile *hf) for this purpose.
- If I put my data in a basecontainer, how do I use the Undo, i.e. what must I put for data in the function AddUndo(LONG type, void* data), the basecontainer in which are stored my data?

Thanks again in advance,
Myel

CGTalk Moderation
03-02-2006, 06:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.