Python tag - IsDirty() not working?
-
I need to check whether the children of an object with Python tag has been changed (added/removed). I tried
obj.IsDirty(c4d.DIRTYFLAGS_CHILDREN)
but it's always "False" whatever happens to the scene. I guess this method is not intended to function in a tag? What to use than?
ā -
IsDirty()
is only relevant in the pipeline of anObjectData
generator plugin (BaseObject Manual).You need C4DAtom.GetDirty() or C4DAtom.GetHDirty() to compare the dirty checksums.
-
This post is deleted! -
Thanks, that's what I thought(
I found a nice dummy tegdTegData python plugin template, for sure somebody needs it too
https://github.com/gundamboy/DummyTagdataPluginTemplate -
@PluginStudent said in Python tag - IsDirty() not working?:
IsDirty()
is only relevant in the pipeline of anObjectData
generator plugin (BaseObject Manual).You need C4DAtom.GetDirty() or C4DAtom.GetHDirty() to compare the dirty checksums.
I'm sorry, but I can't untangle it. I try to execute the following in the tag plugin:
def Execute(self, tag, doc, op, bt, priority, flags): op.SetDirty(c4d.DIRTY_CHILDREN) print op.GetDirty(c4d.DIRTY_CHILDREN)
AttributeError: 'c4d.BaseObject' object has no attribute 'SetDitry'
-
@intenditore said in Python tag - IsDirty() not working?:
AttributeError: 'c4d.BaseObject' object has no attribute 'SetDitry'
According to this error message, you wrote
SetDitry
-
Yeah... I fought with this type for almost a day ;D
But than some weirder things has been discovered.
I have this easy code in TagData plugin:def Execute(self, tag, doc, op, bt, priority, flags): op.SetDirty(c4d.DIRTYFLAGS_CHILDREN) print op.GetDirty(c4d.DIRTYFLAGS_CHILDREN)
It always prints 0, no matter what happens to the children. I also tried other model, DIRTYFLAGS_ALL - there it starts with a small random number and adds 1 every update even if nothing happens. I tried DIRTY_CHILDREN also, the same "0".
Can't get how hierarchy change checking works. And does it? -
Why are you calling
SetDirty()
before callingGetDirty()
?Why not use
GetHDirty(c4d.HDIRTYFLAGS_OBJECT_HIERARCHY)
? (Dirty States) -
@PluginStudent oh God! You helped me so much!
Many thanks for that. Sincerely, it's not very well explained in docs, really not well (in opposite to Undo system for instance) and getting how exactly should it work is tricky. But your last suggestion surely works, and it raises the number every time hierarchy is changed, so I need only check has it been changed or not and than decide to run the code or not (maybe somebody will stuck in the same position so I hope my plain explanation would be useful)
Thanks! -
Hi, I confirmed as @PluginStudent said you should use, HDirty for this purpose.
SetDirty with the flag DIRTYFLAGS_CHILDREN only works for new CCurve and Ckey.
To be honest, I'm not sure why, and it's indeed misleading, I will reach the development team about it, and in any case, will fix the documentation.Cheers,
Maxime. -
@m_adam thank you, that's really confusing..