Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Notification on tag delete or rename

 Post Reply Post Reply
Author
Message
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Topic: Notification on tag delete or rename
    Posted: 2017 Nov 29 at 12:42am

User Information:

Cinema 4D Version:   R19 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

I have noticed that deleting or renaming a tag apparently only triggers an EVMSG_CHANGE to be posted.

When I watch a specific object (the current active one), I can manage to detect this deleting or renaming, since the HDIRTYFLAGS_TAG gets incremented of the object I am watching.
However, when I delete or rename a tag on another object than the currently selected one, I -of course- don't get triggered.

Now, I could start watching every single object in the scene, and react accordingly.
But before I take that route, is there maybe another mechanism to detect what I am looking for.
I am afraid that keeping in sync with the scene population will:
1. be slowing down the system
2. miss some things here and there
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1599
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 29 at 6:17am
Hi,

can you give us some more details about the situation you are in? Plugin type? Use case or goal to achieve?
While asking these questions, I do already have doubts we will be able to provide anything better than EVMSG_CHANGE. This is how Cinema 4D currently works. Of course you could optimize by holding a list of entities you are interested in, but somehow it sounds as if this list would contain everything...

Cheers,
Andreas
SDK Support Engineer
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 29 at 6:39am
Hi Andreas,

Right, forgot the mention the basics.
This is a GeDialog which needs to update a GeUserArea when the tag gets deleted or renamed.

So, I went ahead and wrote a small MessageData plugin for testing purposes, implementing what I mentioned in my original message.

It iterates over the scene hierarchy on every EVMSG_CHANGE and does the following:
- it has a BaseLinkArray as member and iterates over this list, checking if any of the BaseLink is different from nullptr. If nullptr then I know the tag was removed from the scene
- it iterates over the scene objects, and its tags:
  when the tag is present in the BaseLinkArray no action is taken.
  when the tag is not present in the BaseLinkArray it is added (a new tag was created).
Next time a EVMSG_CHANGE comes in, I repeat the whole, and can thus detect if a tag was removed, added, or left untouched

I don't like this repetitive parsing of the scene ad infinitum, but I guess there's no other option.

This however, hasn't resolved my problem of detecting the renaming of a tag.
I thought this was an easy case of checking TagData::SetDParameter for that particular attribute, but I don't get anything triggered remotely close to the Tbase name (I included Tbase in the res file of the tag's description)
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2558
Post Options Post Options   Quote NiklasR Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 30 at 3:48am
Since you're checking for every tag if it already exists in the BaseLinkArray, maybe you should think about using a HashMap<BaseTag*, AutoAlloc<BaseLink>> instead to reduce time complexity.

Cheers,
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 01 at 6:49am
Good point.
But wouldn't I be better of with using a BaseLink as key?
The BaseTag pointer can vary, hence I would detect an existing tag as a new one, since pointers are different.
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2558
Post Options Post Options   Quote NiklasR Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 01 at 12:34pm
I think you've got it mixed up :) The BaseTag pointer will not change for the same tag, but you'll get a different BaseLink pointer everytime you create a new BaseLink for a tag. You should only use the BaseTag pointers as hash keys though, because you won't know if the pointer is valid until you checked the BaseLink.
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 02 at 6:14am
Unfortunately, the BaseTag pointer does change when undo/redo is involved.
But I understand what you mean with the BaseLink.

Actually, using BaseLinkArray does of course also exhibit the same behaviour with undo/redo.
So this whole solution is actually useless.

Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1599
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 04 at 8:22am
On the question of tag renaming or general renaming of entities:
The name of any BaseList2D derived entity is stored in a member variable and not in its BaseContainer among the other parameters. Yet, you get an EVMSG_CHANGE and the dirty flags (DIRTYFLAGS_DATA) change as well.

Just to summarize, with current architecture the workflow usually looks as follows:
- receive EVMSG_CHANGE
- check the entities you are interested in (dirty flags... a BaseLink evaluated in the document is fine to for example detect deleted entities)
- retrieve whatever data you need to display in your dialog, if a change was detected

Cheers,
Andreas
SDK Support Engineer
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 04 at 8:39am
While a BaseObject has a IsDirty() returning a Bool, the other entities only have a GetDirty() returning an Int32. As such, with a BaseObjet I can simply check on the returned Bool value, while for checking other entities I will need to keep the previous dirty state to check against. Correct ?

Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1599
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 05 at 2:47am
No, not quite correct.

Actually you shouldn't use IsDirty() in this context at all. Unfortunately the API reference isn't clear about this. The BaseObject manual is better here and sorts IsDirty() under the "Generating" functions.
The point is, IsDirty() is supposed to be used in GetVirtualObjects() (et al.), so during scene building/evaluation. And there it returns, if "an object is dirty since it got touched last". Only the instance touching for example input objects can expect reliable results from this function.

Instead you will always have to use the dirty counts returned from the GettDirty() functions and these always need to be compared to stored old values. Also one shouldn't try to interpret anything into the amount these dirty counts change, but only check on (in-)equality compared to the old value.



Edited by Andreas Block - 2017 Dec 05 at 9:36am
Cheers,
Andreas
SDK Support Engineer
Back to Top
C4DS View Drop Down
Member
Member


Joined: 2015 Dec 01
Online Status: Offline
Posts: 157
Post Options Post Options   Quote C4DS Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Dec 05 at 6:15am
OK, I see.

Well, I asked about this dirty value difference in another thread. But from your comment here I understand there is no logic behind it, so simply ignore that question in the other thread.
Thanks.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.