<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to send data from python to my c++ plugin?]]></title><description><![CDATA[<p dir="auto"><em>On 17/07/2018 at 06:48, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi everyone.</p>
<p dir="auto">Not sure if this is the right branch of forum, but I think that problem is in my python code..</p>
<p dir="auto">I'm trying to learn C4D CPP API and I've stucked. I can't figure out how to read the data that i sent from python node to my c++ TagData plugin with Message().</p>
<p dir="auto">My plugin code(part of it) :</p>
<pre><code>MyTestPlugin.cpp   
class MyTestPlugin:TagData{  
...  
...  
Bool MyTestPlugin::Message(GeListNode *node, Int32 type, void *data)  
{  
  if (type == 322)  
  {  
      GePrint("___Event Fired___");  
      if (!data)  
          return false;  
      GePrint(String::IntToString( (Int32)data ));  
      GePrint(String::IntToString( *(Int32* )data ));  
  }  
  return true;  
}  
...  
...  
</code></pre>
<p dir="auto">And my python code(XPresso node) looks like:</p>
<pre><code>import c4d
  
def main() :  
  _myCustomTag.Message(322, 112233)  
  
</code></pre>
<p dir="auto"><strong>The output:</strong><br />
___Event Fired___<br />
415747088<br />
15</p>
<p dir="auto">If I'm not mistaken the problem is that python sends message with <strong>&lt; Int32&gt;</strong> data inside and cpp waits for <strong>&lt; Int32*&gt;</strong>. But I just can't figure out what to do.(((<br />
Please help.</p>
]]></description><link>http://developers.maxon.net/forum/topic/10871/14314_how-to-send-data-from-python-to-my-c-plugin</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 22:47:06 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10871.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Sep 2018 10:48:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to send data from python to my c++ plugin? on Sat, 01 Sep 2018 10:48:19 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 04/08/2018 at 03:54, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Sorry for late reply.<br />
Thanks for your answer - it helped me a lot.</p>
<p dir="auto">Actually, it's strange that you have to use BaseContainer wrap for every piece of primitive data. I think sometimes it must be seriously hurting perfomance.<br />
Anyway, thanks again, Maxime. Best wishes.</p>
]]></description><link>http://developers.maxon.net/forum/post/55259</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55259</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:48:19 GMT</pubDate></item><item><title><![CDATA[Reply to How to send data from python to my c++ plugin? on Sat, 01 Sep 2018 10:48:16 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 18/07/2018 at 06:42, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi dmitry82,</p>
<p dir="auto">Actually, the problem is that you are sending a python object to a C++.<br />
So the best way to do it is to use a BaseContainer to send your data, and use MSG_BASECONTAINER.</p>
<p dir="auto">So your C++ code will looks like</p>
<pre><code>if (type == MSG_BASECONTAINER)
{
	GePrint("___Event Fired___");
	if (!data)
		return false;
	BaseContainer* bc = (BaseContainer* )data;
	if (bc == nullptr)
		return false;
  
	Int32 value = bc-&gt;GetInt32(0, 10);
}
</code></pre>
<p dir="auto">and your python code</p>
<pre><code>bc = c4d.BaseContainer()
bc[0] = 100
_myCustomTag.Message(c4d.MSG_BASECONTAINER, bc)
</code></pre>
<p dir="auto">Please note Message function is executed immediately when you call it, that means you get the same limitation as you get in a threaded context (Xpresso Node), which is to not change the scene structure within this call, for more information please read the <a href="https://developers.maxon.net/docs/cpp/2023_2/page_manual_cinemathreads.html" target="_blank" rel="noopener noreferrer nofollow ugc"> C++ Manual about threading</a>.</p>
<p dir="auto">If you have any question, please let me know,<br />
Cheers,<br />
Maxime</p>
]]></description><link>http://developers.maxon.net/forum/post/55258</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55258</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:48:16 GMT</pubDate></item></channel></rss>