Undo of inserting a tag
pim last edited by s_bach
I have a tag plugin where I move tags from one object to another.
I tried several Undo types, but I cannot get it working.
What to do?
childTags = child.GetTags() .... for childTag in childTags: #doc.AddUndo(c4d.UNDOTYPE_CHANGE, object) doc.AddUndo(c4d.UNDOTYPE_HIERARCHY_PSR, object) object.InsertTag(childTag) #doc.AddUndo(c4d.UNDOTYPE_NEW, object)
zipit last edited by zipit
undo-steps for inserting objects have to be added after the the object has been inserted; the appropriate flag is then
c4d.UNDOTYPE_NEW. Could you describe in more detail what is not working?
s_bach last edited by s_bach
an undo-step has to start with
StartUndo()and must end with
EndUndo(). In between, you can add operations to that undo-step with
AddUndo(). As @zipit has shown, the undo-operation for adding something to the document is
doc.StartUndo() ttag = c4d.TextureTag() op.InsertTag(ttag) doc.AddUndo(c4d.UNDOTYPE_NEW, ttag) doc.EndUndo()
See also Undo System Manual.
s_bach last edited by
Also, if you want to move a tag, you first have to remove it from the original object. So you don't insert, you change the position of the tag in the scene graph.
doc.StartUndo() doc.AddUndo(c4d.UNDOTYPE_CHANGE, tag) tag.Remove() op.InsertTag(tag) doc.EndUndo()