On 28/05/2018 at 23:52, xxxxxxxx wrote:
Cinema 4D Version: R19
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;
I am currently investigating the feasability of a new plugin.
Parsing the SDK documentation in search of collecting the required information I ended up having more questions than answers.
I understand the forum to encourage a single question per thread.
But since most questions are related to each other, and due to their common context, I hope it is OK for me to list the questions here.
I 'd be happy to split off the questions into their own thread should the discussion require it, or steer into that direction.
The main topic for his plugin is the detection of change of polygons for a polygon object.
We've discussed this in the past (for another plugin), and the MSG_POLYGONS_CHANGED then came up.
This message would be sent to a (hidden) tag assigned to the polygon object. Let's call this the "ListenerTag", for future reference.
Q1: is there another type of plugin which could receive this message, apart from a tag plugin?
Reason for this question is that I would want to avoid adding a tag to the object.
When user would share this object with others not having the tag plugin, a message would popup mentioning the missing ListenerTag plugin. Not a big deal, but I would want to avoid this.
I then noticed MSG_DOCUMENTINFO_TYPE_SAVE_BEFORE which could be received by a SceneHook plugin when the scene is about to be written.
Q2: Could I detect MSG_DOCUMENTINFO_TYPE_SAVE_BEFORE in a SceneHook data, and remove the ListenerTag from the object(s)?
Is it save to remove tags right before writing the scene file? Will the saved scene file indeed NOT contain the ListenerTag, avoiding the "missing plugins" message pop up when user loading this scene file, not having the ListenerTag plugin installed?
The alternative for when the whole idea -of using a ListenerTag and specially removing it before saving the scene file- is too far fetched and unusable:
Using a MessageData I could detect EVMSG_CHANGE, check for the dirty count, or get the polygon count from the Polygon tag.
Comparing this value with some stored value in a custom BaseContainer in the object. When values are different this means the poylgon count has changed, and I update the stored value with the new polygon count.
I could, similar to the ListerenTag idea, remove the custom container from the object once the scene files get saved.
But I wouldn't mind leaving it, as it only represents a few bytes.
Q3: does an object containing a custom BaseContainer (using a registered plugin ID) trigger a "missing plugin" message, when plugin is not installed?
I don't think so, because a plugin ID for a custom BaseContainer does not necessarily mean there exists a plugin with this ID. Just like plugin IDs are used for specific messages being sent via SpecialEventAdd.
Still, better be safe than sorry and ask.
Q4: what in case I decide I want to remove the custom BaseContainer before user saves the scene file, can I do so by receiving the MSG_DOCUMENTINFO_TYPE_SAVE_BEFORE and simply removing the basecontainer from the object?
Q5: are there next to MSG_POLYGONS_CHANGED or EVMSG_CHANGE other options to detect a change of geometry / toplogy?
Thanks for reading,
On 29/05/2018 at 07:37, xxxxxxxx wrote:
Q1: MSG_POLYGONS_CHANGED is only sent to tags.
Q2: Yes, that's possible. Be aware though, it is the active document you are working on. So the tag is removed from the active document, unless you take extra measures, e.g. in MSG_DOCUMENTINFO_TYPE_SAVE_AFTER. Also note the corresponding messages for Save Project (MSG_DOCUMENTINFO_TYPE_SAVEPROJECT_BEFORE and MSG_DOCUMENTINFO_TYPE_SAVEPROJECT_AFTER).
Q3: No, such additional information (e.g. a BaseContainer with custom content) in an objects BaseContainer will not trigger the plugins warning.
Q4: Yes, same implication as with Q2, though.
Q5: No, unfortunately not really. Of course you could use Execute() of your tag, but I guess, that's what you are trying to avoid in the first place.
On 29/05/2018 at 08:31, xxxxxxxx wrote:
Thanks for the replies, Andreas.
Very much appreciated.
All clear, except for the answer on Q2.
What extra measures should/could I take during MSG_DOCUMENTINFO_TYPE_SAVE_AFTER ?
The scene file is then already saved. I am not sure to understand your hints exactly as you mean them to be.
Thanks for reminding me of the saveproject messages, I would have missed those.
On 29/05/2018 at 08:34, xxxxxxxx wrote:
Sorry, Daniel, I didn't intend to speak in riddles. My thought was, when you delete a tag before saving, you might want to use the "after" messages to recreate those tags, so the currently active scene remains unaltered for the user.
On 30/05/2018 at 12:55, xxxxxxxx wrote:
Ah, I see.
Actually, I didn't think needing to recreate the tags after saving. But it seems saving the scene files doesn't trigger an EVMSG_CHANGE, hence the "after" message is a very welcome mechanism.