message after tag delete

On 27/04/2014 at 10:55, xxxxxxxx wrote:

I am trying to determine what Cinema sends back to the system as a message when a tag is deleted but I am coming up short. I have a tag plugin i'm working on, and if the tag is deleted I need to do some cleanup elsewhere.

I set up a test to try and determine this as follows:

def Message(self, node, type, data) :
    if type == c4d.xxxxx:

where xxxxx is each type of msg as outlined in the documentation (R15.057) under c4d.plugins.NodeData (even the ones there were absolutely obvious to not be related) ** **

on tag creation i get MSG_MENUPREPARE and also MSG_EDIT, but when deleting the tag I get nothing.

any thoughts?


On 27/04/2014 at 11:08, xxxxxxxx wrote:

Does NodeData::Free get called when tags are deleted? That's where I'd usually do any cleanup.

On 27/04/2014 at 11:10, xxxxxxxx wrote:

ah sorry just saw you're using Python please ignore that!

On 27/04/2014 at 11:12, xxxxxxxx wrote:

but I just checked, the Python SDK has the equivalent NodeData.Free so that might still work for you

On 27/04/2014 at 11:13, xxxxxxxx wrote:

holy crap, yes it does. im so ashamed lol

Thanks @danfitz

On 27/04/2014 at 11:15, xxxxxxxx wrote:

no worries, never be ashamed ;)

On 27/04/2014 at 12:17, xxxxxxxx wrote:

seems I got too excited too soon. NodeData.Free does get called after the tag has been deleted, but also after other interactions as well. for instance, if i use one of the buttons i have added to it via resources. This only seems to happen with BUTTONs though, not BOOLs or LONG fields.

the docs are as follows:
Override - If your class has a destructor it is called as usual after this function.
Parameters: node (GeListNode) – The list node connected with this instance.

so i guess i need to access the destructor or figure out how to detect if its one of the button id's i have.. feels like a vicious circle has started.

On 27/04/2014 at 12:20, xxxxxxxx wrote:

hi Charles just saw your Twitter reply (oh and here too now) - I wonder if you could try checking GetObject() on the tag node that gets passed to the Free() function, if it gets called after being removed from the object that might return 'None' (if it gets called beforehand it'll probably return the object so won't be much good to you). Getting hackier but might work!

On 27/04/2014 at 18:17, xxxxxxxx wrote:

I havent figured out an answer to this yet, buy Dan and I had some twitter conversations about it. For continuity I'm pasting that conversation here in hopes that it might help someone else thing of a answer.

Dan Fitzgerald @D_Fitz_G
@RagingClaw haha no worries, glad that worked out!

Charles Rowland @RagingClaw 
@D_Fitz_G weird, NodeData.Free seems to be called after any interaction, not just deletions.

Dan Fitzgerald @D_Fitz_G
@RagingClaw that's not that useful then! Just replied to your last post on plugincafe

Charles Rowland @RagingClaw 
@D_Fitz_G just read.  its calling it before the deletion. printing the Node brings up the tag id.

Dan Fitzgerald @D_Fitz_G
@RagingClaw try printing node.GetObject() - that returns the object the tag is attached to, if it's been deleted it shouldn't be attached to

Dan Fitzgerald @D_Fitz_G
@RagingClaw anything and that should return 'None' (hopefully)

Charles Rowland @RagingClaw 
@D_Fitz_G this is the code block

Charles Rowland @RagingClaw 
@D_Fitz_G this is after pushing delete 1 time

Charles Rowland @RagingClaw 
@D_Fitz_G looks good at first glance, but then…. if i push a BUTTON on the tag (after clearing console)

Charles Rowland @RagingClaw 
@D_Fitz_G looks that hidden null is titled the same as the tags id, so i could compare lists when MSG_EDIT is called, but that sucks

Charles Rowland @RagingClaw 
@D_Fitz_G but ultimately i don't want to use a null at all, i want to store them in memory but can't get that working

Dan Fitzgerald @D_Fitz_G
@RagingClaw ah that's pretty weird, are both outputs being sent by the same copy of the tag? I wonder if it's making a copy for undo

Dan Fitzgerald @D_Fitz_G
@RagingClaw or you could try the opposite, on Free() check the tags of the object your tag was attached to, see if your tag is still there,

Dan Fitzgerald @D_Fitz_G
@RagingClaw would need to keep a reference in your code of which object you were on, then try using GetTags() on it

Charles Rowland @RagingClaw 
@D_Fitz_G thats what I'm trying now

Dan Fitzgerald @D_Fitz_G
@RagingClaw cool, let me know if it works out

Charles Rowland @RagingClaw 
@D_Fitz_G this is interesting, the Init() method is called when deleting the tag. WTF?

Charles Rowland @RagingClaw 
@D_Fitz_G if init() is called, hmmm i have an idea

Dan Fitzgerald @D_Fitz_G
@RagingClaw intriguing - I'm about to watch an episode of Angel, I'll check in again afterwards!

Dan Fitzgerald @D_Fitz_G
@RagingClaw any luck?

Charles Rowland @RagingClaw 
@D_Fitz_G not unless you count that all the punching on my desk hasn't broken the desk or my hand.. then, thats luck.. so, no. BAH!

Charles Rowland @RagingClaw 
@D_Fitz_G i tried making a global flag and hitting in during init() but that too is registering twice at a time. le sigh.

Charles Rowland @RagingClaw 
@D_Fitz_G i have to grill dinner. when I'm done, ill put together a dummy tag plugin and put it up on the forum. maybe someone can get it

@RagingClaw good plan. I'm out of ideas for now but if I think of anything I'll let you know

Dan Fitzgerald @D_Fitz_G
@RagingClaw seems like there should be a super simple way to do this, hopefully someone else has some more info we're missing

Charles Rowland @RagingClaw 
right! why the hell is there no destroy method

Dan Fitzgerald @D_Fitz_G
@RagingClaw I'm off to bed, good luck!

for those curious, I grilled some brats and they were delicious

On 27/04/2014 at 20:09, xxxxxxxx wrote:

I added the dummy tag plugin to a GIT repo

On 28/04/2014 at 00:35, xxxxxxxx wrote:

Hi Charles,
I've just had a very quick mess about with your tag plugin template, adding just a print to the Free() function:

def Free(self, node) :  
      Override - If your class has a destructor it is called as usual after this function.  
      print "free"  

and it seems to be working for me - the button prints "congratulations, you have successfully pushed a button." when I click it (and it doesn't print "free"), and deleting the tag just prints "free". The only weirdness I had was in R15 when deleting the tag would print "free" twice, but still no crossover from pressing the button. But works perfectly in R13 and 14.

Maybe some of your button code is causing Free to be called too? The SDK says that after node.Write() is called node.Free() gets called, so anything that causes Write to happen (I don't know what those things might be, other than saving) will cause Free too, so that could be a source of unexpected Freeing.

On 28/04/2014 at 00:56, xxxxxxxx wrote:

Free() is not reliable for this use, it is called for copies of the tag that are put on the undo stack as well. Have you checked if there was
a message sent to the tag when it is deleted?  nvm, that's what you said in your first post.

I'll try to find something.