Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Save node data in Read and Write

    Cinema 4D SDK
    3
    5
    960
    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.
    • M
      mike
      last edited by mike

      hi,this is my code ,i save data in node ,but can't read successlly ,just display 0. Where did I go wrong?

      Bool TagTest::Read(GeListNode * node, HyperFile * hf, Int32 level)
      {
      	BaseTag* op = (BaseTag*)node;
      	BaseContainer* bc = op->GetDataInstance();
      	ApplicationOutput("Read count: @ ", bc->GetInt32(12345));
      	return SUPER::Read(node, hf, level);
      	return true;
      }
      
      Bool TagTest::Write(GeListNode * node, HyperFile * hf)
      {
      	BaseTag* op = (BaseTag*)node;
      	BaseContainer* bc = op->GetDataInstance();
      	bc->SetInt32(12345,123);
      	ApplicationOutput("Write count: @ ", bc->GetInt32(12345));
      	return SUPER::Write(node, hf);
      	return true;
      }
      

      Hope your help.

      1 Reply Last reply Reply Quote 0
      • fwilleke80F
        fwilleke80
        last edited by

        If you're storing data in the tag's BaseContainer, you don't need to override Write() and Read(). That's meant for private class member whose data would be lost otherwise.

        Also, you can remove the "return true" at the end of the functions. As you already return in the previous line, it will never be called.

        www.frankwilleke.de
        Only asking personal code questions here.

        M 1 Reply Last reply Reply Quote 1
        • M
          mike @fwilleke80
          last edited by

          @fwilleke80 Thank you for your help! I mistakenly believe that Write is the extra func to save data.

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            Hi @mike,

            This is true only for data that are not stored in a BaseContainer (e.g. you want to store a BaseArray).
            For more information please read NodeData::Read() / NodeData::Write() Manual and in case you override Read/Write you may also want to override CopyTo, see NodeData::CopyTo() Manual in order to define the behavior of your NodeData when its copied. But again this is in the case you use some datatype that is not part of the BaseContainer object.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            M 1 Reply Last reply Reply Quote 2
            • M
              mike @m_adam
              last edited by

              @m_adam Thank your for your answer

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