<?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[Dynamically changing custom icon of TagData Plugin]]></title><description><![CDATA[<p dir="auto">Hi guys,</p>
<p dir="auto">I have a tag plugin which makes use of <code>c4d.MSG_GETCUSTOMICON</code> <a href="https://developers.maxon.net/forum/topic/11289/dynamically-changing-icons?_=1694509021623" target="_blank" rel="noopener noreferrer nofollow ugc">stole the code from here</a> to dynamically change its icon based on a parameter of the tag.</p>
<p dir="auto">While this is all fine and dandy, I encountered the problem that this only works if I add the tag to a single object. The minute I have multiple objects selected and add my tag plugin to them, the first (or last, depending how you want to see it) always loads the wrong icon while the other objects get the correct one. See pictures below.</p>
<p dir="auto"><strong>Wrong behaviour:</strong><br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1694509603244-not_working.jpg" alt="Not_Working.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto"><strong>Expected behaviour:</strong><br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1694509648193-working.jpg" alt="Working.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">My feeling is, that <code>c4d.MSG_MENUPREPARE</code> is the culprit here and only gets called for a single instance of the tag. Not sure though.</p>
<p dir="auto">To circumvent this I implemented a <code>c4d.plugins.MessageData</code> plugin which reacts to a <code>c4d.SpecialEventAdd()</code> call I send every time <code>c4d.MSG_MENUPREPARE</code> is called received in the tag plugin. So in essence I delegate the work to the MessageData plugin which is now responsible to set the parameter on the tag plugin instances.</p>
<p dir="auto">Long story short - it works. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--smile" style="height:23px;width:auto;vertical-align:middle" title=":D" alt="😄" /><br />
But I wonder if this is "the right" way to do it. As it feels a little bit clunky and also somehow overkill for such a small feature. Imagine having a couple of plugins which all implement some similar feature. All of these plugins would then need a MessageData plugin which communicates with them.</p>
<p dir="auto">So, to finish this of. Could someone tell me if this is the intended approach or if I#m missing something here and doing things unnecessarily complicated?</p>
<p dir="auto">I attached the project so that its easier to follow.</p>
<p dir="auto"><a href="https://developers.maxon.net/forum/assets/uploads/files/1694510303418-tagtest.zip" target="_blank" rel="noopener noreferrer nofollow ugc">TagTest.zip</a></p>
<p dir="auto">Cheers,<br />
Sebastian</p>
]]></description><link>http://developers.maxon.net/forum/topic/15020/dynamically-changing-custom-icon-of-tagdata-plugin</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 20:11:28 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15020.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Sep 2023 09:19:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dynamically changing custom icon of TagData Plugin on Thu, 14 Sep 2023 17:48:26 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/herrmay">@<bdi>HerrMay</bdi></a>,</p>
<p dir="auto">Thank you for the updated information. I had a look at your problem, and I could reproduce it, but it is primarily a problem of your code as suspected.</p>
<p dir="auto">I document below how I analyzed this problem not as a passive aggressive expression of <em>"look how easy that is!"</em>. But to give an insight on how to approach such debugging task. The core rule is here to question one's own assumptions and assure that things are indeed how we think they are.</p>
<h4>Debugging</h4>
<p dir="auto">So, when one follows your steps, one indeed ends up with something like this:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1694702115621-8fdef1aa-1a5e-43d8-8cdb-42b480fd4f0d-image.png" alt="8fdef1aa-1a5e-43d8-8cdb-42b480fd4f0d-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Your assumption here was that the icon handling is bugged on our side. For that to be true, the tag on <code>Null.2</code> would have to be <code>IDC_ACTIVE_ON</code> but with the icon handling failing and Cinemas 4D rendering it as disabled.</p>
<p dir="auto">So, I checked the value with this code:</p>
<pre><code class="language-py">        # Set custom icon for node.
        if id == c4d.MSG_GETCUSTOMICON:
            host: c4d.BaseObject = tag.GetObject()
            isFirst: bool = host.GetUp() == None and host.GetPred() == None
            if isFirst:
                print(f"TOP: {host.GetName() = }, {tag[IDC_ACTIVE] = }")
            else:
                print(f"OTHER: {host.GetName() = }, {tag[IDC_ACTIVE] = }")

            icon = self.PLUGIN_ICON_INACTIVE if tag[IDC_ACTIVE] == IDC_ACTIVE_OFF else self.PLUGIN_ICON_ACTIVE

            data["bmp"] = icon
            data["w"] = icon.GetBw()
            data["h"] = icon.GetBh()
            data["filled"] = True
</code></pre>
<p dir="auto">Which will print this when you add the tags:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1694702486106-baebed6a-fdc0-4d53-8214-1d6b2011cad8-image.png" alt="baebed6a-fdc0-4d53-8214-1d6b2011cad8-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So, the topmost tag is indeed inactive and the icon rendering is correct. The question is now: <em>'Why is that tag inactive because we initialize all tags as <code>node[IDC_ACTIVE] = IDC_ACTIVE_ON</code> ?'</em> The likely culprit is just a few lines above, as we toggle there the active state of our tag.</p>
<pre><code class="language-py">        # Handle double click on tag.
        if id == c4d.MSG_EDIT:
            if tag[IDC_ACTIVE] == IDC_ACTIVE_OFF:
                tag[IDC_ACTIVE] = IDC_ACTIVE_ON
            else:
                tag[IDC_ACTIVE] = IDC_ACTIVE_OFF
</code></pre>
<p dir="auto">And indeed, when we comment out these lines, we end up with this when creating multiple new tags.</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1694702820259-ebddd8e2-ff78-47f3-a4ca-40cbd26ac047-image.png" alt="ebddd8e2-ff78-47f3-a4ca-40cbd26ac047-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Moreover, when we revert our change of commenting out that code and test our assumption <em>'only happens for multi-object selections'</em>, we can see that this does not hold true:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1694703033146-e5f2a8dd-2ebd-4555-8188-d769b84895e3-image.png" alt="e5f2a8dd-2ebd-4555-8188-d769b84895e3-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">We can now check our own comment:</p>
<pre><code># Handle double click on tag.
if id == c4d.MSG_EDIT:
    ...
</code></pre>
<p dir="auto">and check <code>MSG_EDIT</code>:</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1694703119443-de39ee11-81d9-4e68-a2a6-a4c4dd182b84-image.png" alt="de39ee11-81d9-4e68-a2a6-a4c4dd182b84-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The documentation says, "for example". So, the event does not capture a double click, but double clicking a <code>BaseObject</code> to edit its name is one example of an edit event. Adding a tag to an object apparently also emits <code>MSG_EDIT</code> to the tag, and when you have a multi-selection, <code>MSG_EDIT</code> is only emitted to the first element in the selection.</p>
<h4>Conclusion</h4>
<p dir="auto">That behavior of <code>MSG_EDIT</code> in regard to tags and multi-selections is of course quite odd, but I would not consider it to be a bug, as an edit event is not really defined for tags in the first place. And while I understand what you want to do here, I would also say that what you do in <code>MSG_EDIT</code> is a violation of the UX principles of Cinema 4D. Double clicking a tag should not edit a random parameter in it. We strive for Cinema 4D having a seamless UX-experience for users including plugins. So, we rather not support it when plugin authors are trying to break these UX rules.</p>
<p dir="auto">But I will nevertheless talk with my colleagues about the subject and if we want to consider this behavior of <code>MSG_EDIT</code> to be a bug.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/72452</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72452</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Thu, 14 Sep 2023 17:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamically changing custom icon of TagData Plugin on Thu, 14 Sep 2023 06:41:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a>,</p>
<p dir="auto">alrighty, understood. I know you don't have either the time nor the permission to go on deep bug hunting tours. So no worries there. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">I stripped down the code to the bare minimum. That way it should be easier.</p>
<p dir="auto">Please find below the new project.</p>
<p dir="auto"><a href="https://developers.maxon.net/forum/assets/uploads/files/1694673441243-donothingtag.zip" target="_blank" rel="noopener noreferrer nofollow ugc">DoNothingTag.zip</a></p>
<p dir="auto"><strong>To mimic what I've down please follow these steps. Tested in 2023.2.1</strong></p>
<ol>
<li>
<p dir="auto">Install the "Do Nothing Tag" Plugin from the ZIP-Archive.</p>
</li>
<li>
<p dir="auto">Create some objects. Doesn't matter what kind.</p>
</li>
<li>
<p dir="auto">Select all of these objects and apply the "Do Nothing Tag" from the extensions submenu inside the tag menu.</p>
</li>
<li>
<p dir="auto">You see the topmost object of the selection gets the red icon while the others get the green one.</p>
</li>
</ol>
<p dir="auto">I hope I could be more helpful with these informations. If not, don't hesitate to tell me what I could provide additionally.</p>
<p dir="auto">Thank you,<br />
Sebastian</p>
]]></description><link>http://developers.maxon.net/forum/post/72436</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72436</guid><dc:creator><![CDATA[HerrMay]]></dc:creator><pubDate>Thu, 14 Sep 2023 06:41:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamically changing custom icon of TagData Plugin on Wed, 13 Sep 2023 12:28:29 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/herrmay">@<bdi>HerrMay</bdi></a>,</p>
<p dir="auto">I unfortunately do not have the time to go bug hunting on my own. Debugging of user projects is out of scope of support in general as stated in our <a href="https://plugincafe.maxon.net/guidlines_cp" target="_blank" rel="noopener noreferrer nofollow ugc">guidelines</a>. I doubt there is a bug in our icon handling, so there is more likely a problem in your logic.</p>
<p dir="auto">Please provide code and clear instructions on how to reproduce the problem, preferably in the (1, 2, 3, ...) manner as shown above. Otherwise, I will not be able to make here an exception and help you debugging this.</p>
<p dir="auto">Cheers,<br />
Ferdiand</p>
]]></description><link>http://developers.maxon.net/forum/post/72427</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72427</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 13 Sep 2023 12:28:29 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamically changing custom icon of TagData Plugin on Wed, 13 Sep 2023 12:18:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a>,</p>
<p dir="auto">ah stupid me. I forgot to remove the <code>GetDEnabling</code> part. Didn't mean to bring that along.</p>
<p dir="auto">My problem is not so much about enabling or disabling the node(s) but more the fact that some nodes are simply getting the "wrong" icon status when the tag is apllied from the menu.</p>
<p dir="auto">Try to comment <code>def CoreMessage(self, id, bc)</code> in the <code>TagTestMessageHandler</code> class and then reload the plugin and apply the tag to your object selection again. You should see that the topmost object gets the red icon while the others get the expected green one.</p>
<p dir="auto">Cheers,<br />
Sebastian</p>
]]></description><link>http://developers.maxon.net/forum/post/72426</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72426</guid><dc:creator><![CDATA[HerrMay]]></dc:creator><pubDate>Wed, 13 Sep 2023 12:18:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamically changing custom icon of TagData Plugin on Wed, 13 Sep 2023 12:19:45 GMT]]></title><description><![CDATA[<p dir="auto">Hello @HerrMay.</p>
<p dir="auto">Thank you for reaching out to us. While I sort of understand what you are talking about, I struggle quite a bit with this:</p>
<blockquote>
<p dir="auto">While this is all fine and dandy, I encountered the problem that this only works if I add the tag to a single object. The minute I have multiple objects selected and add my tag plugin to them, the first (or last, depending how you want to see it) always loads the wrong icon while the other objects get the correct one. See pictures below.</p>
</blockquote>
<p dir="auto">When I run your plugin on <code>2023.2.1</code>, and try to roughly mimic what you are talking about, I end up with this:</p>
<p dir="auto"><video class="embed-video-local" controls src="https://developers.maxon.net/forum/assets/uploads/files/1694601111287-34658346587346.mp4">
<p dir="auto">First, I thought something is broken with tri states (i.e., being able to select multiple nodes and edit parameters with overlapping IDs in all selected nodes at once), because the tri states seemingly break as soon as you select "off". But in the video above I realized then that also a singular parameter is being grayed out when you select "off", meaning that you must have implemented <code>GetDEnabling</code>.</p>
<p dir="auto">And sure enough, you do this:</p>
<pre><code>def GetDEnabling(self, node, id, t_data, flags, itemdesc):
    """
    """
    if node[IDC_ACTIVE] == IDC_ACTIVE_OFF:
        return False

    return True
</code></pre>
<p dir="auto">Which is a bit odd to say the least, because toggling <code>IDC_ACTIVE</code> to "off" will effectively brick your tag, since it will disable all parameters, including <code>IDC_ACTIVE</code> itself.</p>
<p dir="auto">Other than that, and as shown in the video, I was not able to reproduce your problem. You should share a step-by-step reproduction in a form as such:</p>
<pre><code class="language-txt">Reproduce
---------

1. With the Create/Mesh/Cube entry add a cube object to a scene.
2. For that new cube object, in the Attribute Manager:
  I. Set the Segments.X parameter to 42.
  II. Check the Separate Surfaces parameter.

Result
------

1. The cube object is shown as a sphere in the viewport.
2. All parameter changes made to the Attribute Manager for such malformed cube object are being ignored, the object is permanently broken.
</code></pre>
<p dir="auto">Cheers,<br />
Ferdinand</p>
</video></p>]]></description><link>http://developers.maxon.net/forum/post/72424</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72424</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 13 Sep 2023 12:19:45 GMT</pubDate></item></channel></rss>