Questions about NodeData::CopyTo()



  • Hi,
    I konw rewrite NodeData::CopyTo() can transmit data after click undo(my tag plugin on the polygon), so my tag data will not lose . but after insert "ApplicationOutput("CopyTo"_s)" in CopyTo(), i see not only "Undo" will call CopyTo(), even drag other tag or move points also call CopyTo() , these actions will not clear my tag data even if i am not rewrite CopyTo() or just write "return true" on the CopyTo() frist line. So, when these actions happened, CopyTo() will result in additional overhead . how can I improve this situation? i try to detect destination node but it always return initialized data. also try to use MSG_DOCUMENTINFO_TYPE_UNDO assess the situation, but this message will be recived after CopyTo().
    hope your help!



  • hello @mike,

    This functions is called a lot of times.
    If the object is changed in some way, a copy of it have to be created and the tag attached to the object are also recreated. CopyTo is used to transfer the data. That's why this function can be called even if you didn't touched the object itself.

    hope it answer your question.

    Cheers
    Manuel



  • @m_magalhaes Thank your for your answer. i am confuse about sametimes even if not rewrite CopyTo() or just write "return true" on the CopyTo() frist line , my data will not lose, this means sometimes do CopyTo() is waste time,how can i avoid it? use flag to distinguish the time i need to copy data and other return ?
    hope your help.



  • well @mike, this depends on where you are storing your data. If your data are stored in the BaseContainer 's object, it will be handled automatically (even when you save your document and that's why we do use the BaseContainer as mush as possible). In this case you don't have to override CopyTo function.

    If you can't really use the BaseContainer you can use the object itself to store your data and this is where you have to implement CopyTo / Read / Write (often if you have to implement one, you should implement all three)

    Maybe by reading the CopyTo manual and Read/Write Manual it could be a bit more clear.

    If you can tell more about your project that could help a bit maybe, what kind of data are you storing in your tag ?

    And don't be afraid of the function being called too often, if it's doing nothing it will not kill Cinema4D.

    Cheers
    Manuel



  • @m_magalhaes sorry,maybe i am not express clearly, i use basearray to keep data(private) . except undo,other operates i test what will call copyto(), not clear my private data (automatically copy or just not do anything) even if not rewrite copyto() or only write :return true ,such as move point and exchange tag order. it means copyto() only work correctly when undo ,other time is waste. i just want find a way to distinguish operate is undo or not undo when copyto() ,help me judge return or copy, because if my basearray store a lot of data, such as one object points pos,every copyto() will expend much time.



  • This post is deleted!


  • hello @mike

    There's no solution to know if the CopyTo() have been called because of an "undo" As i said, CopyTo() can be called a lot of times.

    If you really have an issue with too many data stored in your tag and with the CopyTo(), than you can store your data somewhere else and use a pointer in you tag.

    Cheers
    Manuel



  • @m_magalhaes Thank you for your patient answers.


Log in to reply