[SOLVED] NULL document

On 02/06/2016 at 05:41, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R17 
Platform:   Windows  ;   
Language(s) :     C++  ;


I have written a Read method on a TagData but the node's document is always null for a specific scene.
The reason why I need this Read method is to change the values of some parameters as loaded by the user.

Bool MyTagData::Read(GeListNode* node, HyperFile* hf, Int32 level){
	bool read_successfully = NodeData::Read(node, hf, level);
	BaseDocument* doc = node->GetDocument();
	//if the loaded is an old version
	//     code
	return true;

The problem is that the doc variable is null when retrieved from node.
What causes this issue ?

If you need more information please let me know.

Thank you very much for your time.

On 02/06/2016 at 06:20, xxxxxxxx wrote:


while in Read() the node is not yet part of a document (at least not completely).
Instead implement Message() and react onto MSG_DOCUMENTINFO, subtype MSG_DOCUMENTINFO_TYPE_LOAD.

On 02/06/2016 at 06:42, xxxxxxxx wrote:


Thank you very much for your response.
What I have to do is to change the type of some parameters from one type to another and to do that I need to check the level of the document.

How can I get the level of the document on load in a message callback ?

Thank you.

On 02/06/2016 at 07:37, xxxxxxxx wrote:

What do you mean by 'level of the document'?  Do you mean C4D version of the document?

Your plugins can have levels associated with them (in the Register methods and checked in Read/Write/CopyTo) but they are unrelated to the document.  In this case, you could store the level in the descriptions (hidden), but that wouldn't really be backward compatible for something already out in the wild.

On 02/06/2016 at 13:16, xxxxxxxx wrote:

I need to run code in MSG_DOCUMENTINFO_TYPE_LOAD callback only if the registered TagData plugin has an old version. Same way as the level parameter of Read(...) method.

this is how I would do it in Read(...)

If (level <= OLD_VERSION) {
   //run code that fixes the parameter types

But since the node's document is not valid inside Read... I have to move the code in MSG_DOCUMENTINFO_TYPE_LOAD event's callback.


On 02/06/2016 at 14:22, xxxxxxxx wrote:

Load your data into the Tag. Do not do any changes here yet to your parameters. Just store all the data you need when reading it into your own member variables.

Then when MSG_DOCUMENTINFO_TYPE_LOAD comes in, from a scenehook, run through all the tags in your scene and adjust them.

On 03/06/2016 at 01:42, xxxxxxxx wrote:

Well, Kent said it all.
Of course you could also use the BaseContainer of your tag to transfer the information.

On 04/06/2016 at 11:47, xxxxxxxx wrote:

Thank you very much for your solution.