Solved How to updata message when i save data in NodeData::Message

This is my code.BUTTON_SET and BUTTON_READ is button. I hope save data in tag just like python,but when i click BUTTON_READ after BUTTON_SET, it just print 0 , the default value.I guess i need to update message.So,what should I do? or just where did I go wrong?
Hope your help!

Bool MyTestTagPlugin::Message(GeListNode *node, Int32 type, void *data)
{
        if (type == MSG_DESCRIPTION_COMMAND) 
        {
                DescriptionCommand* dc = (DescriptionCommand*)data;
		const Int32 id = dc->_descId[0].id;
		switch (id)
		{
		  case BUTTON_SET:
                  {
                      BaseTag* tag = (BaseTag*)node;
		      BaseContainer* bc = tag->GetDataInstance();
                      bc->SetInt32(ID_MyTestTagPlugin,10);
                      return true;
                      break;
                 }
                  case BUTTON_READ:
		 {
                      BaseTag* tag = (BaseTag*)node
                      BaseContainer* bc = tag->GetDataInstance(); 
                      GePrint(maxon::ToString(bc->GetInt32(ID_MyTestTagPlugin), false));
                      return true;
                      break;
                 }
        }
      return true
}

Hi Mike, thanks for reaching out us.

With regard to your question, I've had no issue in running something very similar to your code.
Just one note: the ID you're using to store the value in the BaseContainer doesn't have to coincide with the one you're using to register your plugin, is this the case?

On my side I have:

	// cast to BaseTag and check
	BaseTag* customTag = static_cast<BaseTag*>(node);
	if (!customTag)
		return false;
	
	// retrieve the associated BaseContainer and checl
	BaseContainer* customTagBC = customTag->GetDataInstance();
	if (!customTagBC)
		return false;
	
	// switch on message type
	switch (type)
	{
		// Description Command
		case MSG_DESCRIPTION_COMMAND:
		{
			DescriptionCommand* const dc = (DescriptionCommand*)data;
			if (!dc)
				return false;
			// check the descId and act consequently
			if (dc->_descId[0].id == T_PC11485_BUTTON_SET)
			{
				Int32 currentVal = customTagBC->GetInt32(T_PC11485_VALUE);
				customTagBC->SetInt32(T_PC11485_VALUE, currentVal + 1);
			}
			if (dc->_descId[0].id == T_PC11485_BUTTON_GET)
			{
				ApplicationOutput("Value: @", customTagBC->GetInt32(T_PC11485_VALUE));
			}
			break;
		}
	}

for T_PC_11485.h

#ifndef T_PC_11485_H__
#define T_PC_11485_H__

enum
{
	T_PC11485_BUTTON_SET = 1000,
	T_PC11485_BUTTON_GET,
	T_PC11485_VALUE
};

#endif // T_PC_11485_H__

and for T_PC_11485.res

CONTAINER T_PC11485
{
	NAME T_PC11485;
	INCLUDE Tbase;

	GROUP ID_TAGPROPERTIES
	{
		BUTTON T_PC11485_BUTTON_SET	{}
		BUTTON T_PC11485_BUTTON_GET	{}
	}
}

Hope this helps, Riccardo

HyperFile is very useful,cinema4dsdk:objectdata_hyperfile help me implement the function,but i also want to Know how to save data in nodedata just like python?

Hi Mike, thanks for reaching out us.

With regard to your question, I've had no issue in running something very similar to your code.
Just one note: the ID you're using to store the value in the BaseContainer doesn't have to coincide with the one you're using to register your plugin, is this the case?

On my side I have:

	// cast to BaseTag and check
	BaseTag* customTag = static_cast<BaseTag*>(node);
	if (!customTag)
		return false;
	
	// retrieve the associated BaseContainer and checl
	BaseContainer* customTagBC = customTag->GetDataInstance();
	if (!customTagBC)
		return false;
	
	// switch on message type
	switch (type)
	{
		// Description Command
		case MSG_DESCRIPTION_COMMAND:
		{
			DescriptionCommand* const dc = (DescriptionCommand*)data;
			if (!dc)
				return false;
			// check the descId and act consequently
			if (dc->_descId[0].id == T_PC11485_BUTTON_SET)
			{
				Int32 currentVal = customTagBC->GetInt32(T_PC11485_VALUE);
				customTagBC->SetInt32(T_PC11485_VALUE, currentVal + 1);
			}
			if (dc->_descId[0].id == T_PC11485_BUTTON_GET)
			{
				ApplicationOutput("Value: @", customTagBC->GetInt32(T_PC11485_VALUE));
			}
			break;
		}
	}

for T_PC_11485.h

#ifndef T_PC_11485_H__
#define T_PC_11485_H__

enum
{
	T_PC11485_BUTTON_SET = 1000,
	T_PC11485_BUTTON_GET,
	T_PC11485_VALUE
};

#endif // T_PC_11485_H__

and for T_PC_11485.res

CONTAINER T_PC11485
{
	NAME T_PC11485;
	INCLUDE Tbase;

	GROUP ID_TAGPROPERTIES
	{
		BUTTON T_PC11485_BUTTON_SET	{}
		BUTTON T_PC11485_BUTTON_GET	{}
	}
}

Hope this helps, Riccardo

@r_gigante Oh!Thank you!The plug-in ID is the reason for the problem,use another shorter number and everything is ok.

Thank your for your help!:relaxed: :relaxed: :relaxed: