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

    How to use object plugin to get data from my tag plug-in

    Cinema 4D SDK
    c++
    2
    3
    624
    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 s_bach

      hi,
      my tag plugin(not Texpression,just Obase) code have public function to return private variable. a button on my object plug-in and my tag is the frist tag on my object. I want use the button to call public function and get the private variable.this is my code, just return 0, i really want to know what should i do.
      hope your help.

      tag plug-in

      mytag.h:

      class MyTag : public TagData{
           public: 
                     ...//ellipsis  virtual  func
                     Int GetValue();
           private:
                     Int  a = 123;
      
      };
      

      mytag.cpp:

      Int MyTag::GetValue(){
           return this->a ;
      }
      

      my object plugin code:

      #include "mytag.h"
      ...
      ...ellipsis
      ....
      Bool MyObject::Message(GeListNode * node, Int32 type, void * data){
                DescriptionCommand* dc = (DescriptionCommand*)data;
                const Int32 id = dc->_descId[0].id;
      	  switch (id)
      	   {
      		case GET_BUTTON:
      		{	
                           BaseObject* bc = (baseobject*)node;
                           BaseTag* tag = bc->GetFirstTag();
                           Int b = ( (MyTag*)tag )->GetValue();
                           GePrint( maxon::ToString(b,false) );
                           break;
                      }
                  }
                  return true;
      }
      
      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        you cannot cast the BaseTag pointer into your plugin class.

        Your plugin class is based on TagData which itself is based on NodeData. So you must get the pointer to the NodeData instance which represents your plugin instance.

        This pointer is obtained with GetNodeData().

        See Basic Classes and Plugin Classes and NodeData for an example.

        In your code, you should also check if the first tag is really your tag and not any other tag.

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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

          @s_bach Thank you for your answer!

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