Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    [SOLVED] NULL document

    SDK Help
    0
    8
    657
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

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

      ---------
      Hello.

      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);
      	assert(read_successfully);
      	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.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        Hi,

        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.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          Hello.

          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.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              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.

              thnx.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

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

                    Thank you very much for your solution.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post