How to use object plugin to get data from my tag plug-in
-
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; }
-
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 -
@s_bach Thank you for your answer!