GetDDescription is called before Read



  • On 15/07/2016 at 06:44, xxxxxxxx wrote:

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

    ---------
    Hello.

    I have a NodeData plugin in which I use the Read(....) method to update the node's data container using 
    SetInt32 method:

    data_container->SetInt32(PARAM_ID, NEW_VALUE).

    The problem is that when the GetDDescription is called, the data container has the old values and not the ones updated in the Read method.

    How can i update the container values properly ?

    Thank you for your time.



  • On 18/07/2016 at 01:33, xxxxxxxx wrote:

    Hello,

    could you post some more complete code that shows what exactly you are doing?

    Best wishes,
    Sebastian



  • On 18/07/2016 at 19:45, xxxxxxxx wrote:

    you should update the data value in SetDParameter not GetDDescription (if I didn't miss something).



  • On 19/07/2016 at 03:30, xxxxxxxx wrote:

    Hello.

    Here is the code from Read method in my VideoPost

    Bool MyVideoPostPlugin::Read(GeListNode* node, HyperFile* hf, LONG level){
    	bool read_successfully = NodeData::Read(node, hf, level);
    	assert(read_successfully);
      
    	if ( level < DUMMY_NEWEST_VERSION ) {
    		BaseContainer* data = ((BaseList2D* )node)->GetDataInstance();
    		Int32 old_param_value = data->GetInt32(MY_PARAM);
    		data->SetInt32(MY_PARAM, old_param_value + 18);
    	}
    	
    	return true;
    }
    

    As you can see, I get the old value and I add 18 to it.

    In GetDDescription I do:

    BaseContainer* data = ((BaseList2D* )node)->GetDataInstance();
    Int32 value = data->GetInt32(MY_PARAM);
    

    and I don't get the updated result.

    Can I use Data instance in Read to update the values ? If not what's the best way to do it ?

    Thank you very much for your time.



  • On 20/07/2016 at 00:05, xxxxxxxx wrote:

    Hello,

    after a simple test it seems that it works fine. The changed value is read correctly in GetDDescription(). Are you sure that the code inside your if-statement is executed?

    Best wishes,
    Sebastian



  • On 20/07/2016 at 01:06, xxxxxxxx wrote:

    Hello.

    Thank you for spending time helping me on this.

    Yes the block inside if-statement is executed. I have noticed though that the BaseContainer pointer  is not the same in Read and in GetDDescription.

    This is how I retrieve the BaseContainer pointer in Read(...).

    BaseContainer* data = ((BaseList2D* )node)->GetDataInstance();
    

    and this is how I retrieve it in GetDDescription :

    BaseList2D* baselist2d = static_cast<BaseList2D*>(Get());
    assert(baselist2d);
    BaseContainer* data = baselist2d->GetDataInstance();
    assert(data);
    

    Thank you again for your time.



  • On 20/07/2016 at 08:23, xxxxxxxx wrote:

    Hello,

    using the code that relies on Get() I still can't reproduce any problem. Is the parameter value changed if you abandon the if-check and force the parameter change on every load operation? Is the parameter value only wrong inside GetDDescription() or also in the context of other member functions?

    Best wishes,
    Sebastian



  • On 21/07/2016 at 00:59, xxxxxxxx wrote:

    Hello.

    The problem was that when I enabled the code with node.SetParameter(.....), after any of these lines is executed, the GetDDescription is called, before Read(...) has finished.

    Thank you for your time and sorry for putting you into troubles.


Log in to reply