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
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

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

    Cinema 4D SDK
    r20 c++
    2
    4
    838
    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 r_gigante

      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
      }
      
      1 Reply Last reply Reply Quote 0
      • M
        mike
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • r_giganteR
          r_gigante
          last edited by r_gigante

          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

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

            @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!☺ ☺ ☺

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