Hey folks,
I encountered Undo
related issue again. It might be due to my lack of understanding for undo things but let me ask you a question.
I wrote a test tag plugin with python which follows another object's position with a little offset.
It simply works but when I undo, the object that has the tag doesn't react until I click somewhere (see below).
Is it possible to solve this issue with python?
I know undo things are prohibited in execute()
of tagdata
, so is there any workaround?
Please help me if you know the solution.
Here's quick code for this.
testtag.pyp
import os
import c4d
from c4d import plugins, bitmaps, utils
PLUGIN_ID = *******
class TestTagData(plugins.TagData):
def Init(self, node):
pd = c4d.PriorityData()
if pd is None:
raise MemoryError("Failed to create a priority data.")
pd.SetPriorityValue(lValueID = c4d.PRIORITYVALUE_MODE, data = c4d.CYCLE_INITIAL)
node[c4d.EXPRESSION_PRIORITY] = pd
return True
def Execute(self, tag, doc, op, bt, priority, flags):
bc = tag.GetDataInstance()
obj = bc.GetLink(c4d.TTEST_TARGET_OBJECT)
if obj is None:
return False
mrx = obj.GetMg()
mrx.off += c4d.Vector(100, 0, 0)
op.SetMg(mrx)
return c4d.EXECUTIONRESULT_OK
if __name__ == "__main__":
plugins.RegisterTagPlugin(id = PLUGIN_ID, str = "Test Tag", info = c4d.TAG_EXPRESSION | c4d.TAG_VISIBLE, g = TestTagData, description = "ttest", icon = None)
ttest.res
CONTAINER Ttest
{
NAME Ttest;
INCLUDE Texpression;
GROUP ID_TAGPROPERTIES
{
LINK TTEST_TARGET_OBJECT
{
ANIM ON;
ACCEPT { Obase; };
}
}