<?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[Creating and initializing nested ObjectData]]></title><description><![CDATA[<p dir="auto">This question is for C++ in C4D 2023.</p>
<h3>Situation</h3>
<p dir="auto">I'm creating an <code>ObjectData</code> plugin, let's call the class <code>Parent</code>. <code>Parent</code> has various properties which allow the user to define its behavior.</p>
<p dir="auto">Then there is another  <code>ObjectData</code>, let's call that one <code>Child</code>. <code>Child</code> is supposed to create a list of <code>Nulls</code>. The count of <code>Nulls</code> as well as their <code>Shape</code> property must be defined by <code>Parent</code> where one of the exposed properties of <code>Parent</code> has an effect on the count while the <code>Shape</code> is determined by some logic in <code>Parent</code>.</p>
<p dir="auto">The crucial part is that both the count and <code>Shape</code> are always set together by <code>Parent</code>. This event must be the trigger for <code>Child</code> to purge its current <code>Nulls</code> and rebuild them from the ground up using the desired <code>Shape</code>. <strong>It is not acceptable to create the <code>Nulls</code> at one point and simply changing the <code>Shape</code> later on, both steps must <em>always</em> occur at the same time.</strong></p>
<p dir="auto">What is the best approach for <code>Parent</code> to trigger this logic in <code>Child</code>?</p>
<h3>Idea 1: <code>Message MSG_DESCRIPTION_POSTSETPARAMETER</code></h3>
<p dir="auto"><code>Child</code> could listen to the <code>MSG_DESCRIPTION_POSTSETPARAMETER</code> in the <code>Message</code> function. This however will be triggered for each changed property separately so I can't exactly trigger the logic at the correct time, <strong>which would break the requirement</strong>. So I don't think this is the way. At least from what I know about this approach.</p>
<p dir="auto">The code in <code>Parent</code> would look something like this:</p>
<pre><code>Int32 childNullsCount = getChildNullsCount();
Int32 childNullsShape = getChildNullsShape();

BaseObject* child = BaseObject::Alloc(Ochild);
BaseContainer&amp; childData = child -&gt;GetDataInstanceRef();
childData-&gt;SetInt32(CHILD_NULLS_COUNT, childNullsCount);
childData-&gt;SetInt32(CHILD_NULLS_SHAPE, childNullsShape);
</code></pre>
<h3>Idea 2: Custom <code>Message</code></h3>
<p dir="auto">I could define a new message ID and pass the data together.</p>
<p dir="auto">Code in <code>Parent</code>:</p>
<pre><code>Int32 childNullsCount = getChildNullsCount();
Int32 childNullsShape = getChildNullsShape();

BaseObject* child = BaseObject::Alloc(Ochild);
// MSG_CHILD_CREATENULLS is defined somewhere else.
child-&gt;Message(MSG_CHILD_CREATENULLS, &amp;CreateNullsData(childNullsCount, childNullsShape);
</code></pre>
<p dir="auto">Code in <code>Child</code>:</p>
<pre><code>Bool Child::Message(GeListNode* node, Int32 type, void* data)
{
    switch (type)
    {
    case MSG_CHILD_CREATENULLS:
        CreateNullsData* createData = static_cast&lt;CreateNullsData*&gt;(data);

        createNullsWithShape(createData-&gt;Count, createData-&gt;Shape);
        break;
    }

    return true;
}
</code></pre>
<h3>Idea 3: Custom function in <code>Child</code></h3>
<p dir="auto"><code>Child</code> could expose a function like this:</p>
<pre><code>class Child : public ObjectData
{
public:
  /* ... */
  void CreateNulls(Int32 count, Int32 shape);
}
</code></pre>
<p dir="auto"><code>Parent</code> could then do:</p>
<pre><code>Int32 childNullsCount = getChildNullsCount();
Int32 childNullsShape = getChildNullsShape();

BaseObject* child = BaseObject::Alloc(Ochild);
Child* castedChild = /* what code goes here to cast BaseObject* to Child*? */;
castedChild-&gt;CreateNulls(childNullsCount, childNullsShape);
</code></pre>
<p dir="auto">Even if this isn't the way I'd still love to know how to cast <code>BaseObject*</code> to <code>Child*</code>.</p>
<h3>Disclaimer</h3>
<p dir="auto">My actual plugin handles a more complex scenario which would obscure the question too much due to all the details so I'm trying to keep this topic very abstract.</p>
]]></description><link>http://developers.maxon.net/forum/topic/14816/creating-and-initializing-nested-objectdata</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 02:40:42 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/14816.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 Jun 2023 07:52:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Creating and initializing nested ObjectData on Tue, 27 Jun 2023 06:35:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/cjthetiger">@<bdi>CJtheTiger</bdi></a>, the most modular way would be the second one with Message, since it does not require you some weird casting and its pretty generic, so if you change your design you can still rely on the same message to do the things. But there is no wrong way, the one that work the best for you is probably the better.</p>
<p dir="auto">With that's said there is also the <a href="https://developers.maxon.net/docs/cpp/2023_2/class_c4_d_atom.html#afe6d07cc86f15938a233a35c2f56b476" target="_blank" rel="noopener noreferrer nofollow ugc">MultiMessage</a> method that let you send a message directly to multiple objects according to their hierarchical position via the <a href="https://developers.maxon.net/docs/cpp/2023_2/group___m_u_l_t_i_m_s_g___r_o_u_t_e.html" target="_blank" rel="noopener noreferrer nofollow ugc">MULTIMSG_ROUTE</a> input flag.</p>
<p dir="auto">Finally to retrieve the implementation (the NodeData) of a GeListNode(the instance) you can call <a href="https://developers.maxon.net/docs/cpp/2023_2/class_ge_list_node.html#ade67376a1b59027a88727043ca68f6c6" target="_blank" rel="noopener noreferrer nofollow ugc">instance-&gt;GetNodeData&lt;Child&gt;()</a></p>
<p dir="auto">Cheers,<br />
Maxime.</p>
]]></description><link>http://developers.maxon.net/forum/post/71895</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71895</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Tue, 27 Jun 2023 06:35:02 GMT</pubDate></item><item><title><![CDATA[Reply to Creating and initializing nested ObjectData on Mon, 26 Jun 2023 07:32:45 GMT]]></title><description><![CDATA[<p dir="auto">I'm not sure which design decision would be best - Idea 2 and Idea 3 seem pretty much the same, with the small difference that Idea 2 would make this message usable from other places as well. If you would need the functionality only in <code>Parent</code>, then I suppose Idea 3 would be most "encapsulating".</p>
<p dir="auto">And for you SDK query about the data cast - this should do the trick. Usually when doing such node data queries, you should always check the type with <code>GetType()</code>, but since you create the object on the line above, the check would be redundant.</p>
<pre><code>BaseObject* child = BaseObject::Alloc(Ochild);
if (child) {
  Child* castedChild = child-&gt;GetNodeData&lt;Child&gt;();
  castedChild-&gt;CreateNulls(childNullsCount, childNullsShape);
}
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/71886</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71886</guid><dc:creator><![CDATA[Deyan]]></dc:creator><pubDate>Mon, 26 Jun 2023 07:32:45 GMT</pubDate></item><item><title><![CDATA[Reply to Creating and initializing nested ObjectData on Sun, 25 Jun 2023 16:05:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/filip">@<bdi>Filip</bdi></a>,</p>
<p dir="auto">Thanks for your response.</p>
<p dir="auto">The objects must be objects for the user to interact with so the generator approach is not feasible here.</p>
<p dir="auto">Therefore the final result in the scene must be like the following:</p>
<ul>
<li>Parent
<ul>
<li>Child 1
<ul>
<li>Null 1</li>
<li>Null ...</li>
<li>Null n</li>
</ul>
</li>
<li>Child ...
<ul>
<li>Null 1</li>
<li>Null ...</li>
<li>Null n</li>
</ul>
</li>
<li>Child n
<ul>
<li>Null 1</li>
<li>Null ...</li>
<li>Null n</li>
</ul>
</li>
</ul>
</li>
</ul>
<p dir="auto">I'm very aware of (hopefully) all the design considerations that come with this decision. Since I had to consider all the other plugin requirements I'd like to refrain from elaborating on those if possible. Because if I were to do that I'd need an actual plugin architect to re-consider everything from the ground up with me. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f605.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--sweat_smile" style="height:23px;width:auto;vertical-align:middle" title=":sweat_smile:" alt="😅" /></p>
<p dir="auto">Best regards and have a nice Sunday,</p>
<p dir="auto">CJ</p>
]]></description><link>http://developers.maxon.net/forum/post/71879</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71879</guid><dc:creator><![CDATA[CJtheTiger]]></dc:creator><pubDate>Sun, 25 Jun 2023 16:05:43 GMT</pubDate></item><item><title><![CDATA[Reply to Creating and initializing nested ObjectData on Sun, 25 Jun 2023 11:59:05 GMT]]></title><description><![CDATA[<p dir="auto">Do you need to able to place the "Parent" and "Child" objects anywhere in your scene hierarchy? Otherwise, could one possibility be to make "Child" a generator object, that implements GetVirtualObjects() to generate the desired null objects based on the "parent" object? The "parent" object would need to be placed under the "child" object in the hierarchy, which may or may not be a problem depending on the problem you are trying to solve.</p>
<p dir="auto">Or do you also need the generated nulls to be editable, i.e., not virtual objects created by a generator?</p>
<p dir="auto">Best regards<br />
/Filip</p>
]]></description><link>http://developers.maxon.net/forum/post/71878</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/71878</guid><dc:creator><![CDATA[Filip]]></dc:creator><pubDate>Sun, 25 Jun 2023 11:59:05 GMT</pubDate></item></channel></rss>