On 18/07/2013 at 08:51, xxxxxxxx wrote:
Hi Jack,
this is a good question ^^ and a little bit difficult to explain.
Overall...
first i dont need undo for this object, because the plugin is just use in a controller xref. Second i can
t implemented undo the right way, so its better not to do it.
But now its not as simple as it seemed to me before.
Maybe your are able to give me some advices to add undo correctly in my plugin 
My object data plugin translates and rotates polygon objects like a null group.
So i dont have to change the object axis and do it separately. Why i have to develop a plugin for this simple functions? Because of the defined scene structure, i
m not allowed to arrange this polygon objects in a null group together or rearrange the scene structure.
_
Some example code:
_ class Transformator(plugins.ObjectData) :
#...
def Message(self, op, type, data) :
#...
elif type==c4d.MSG_DESCRIPTION_CHECKUPDATE:
self.main(op)
def main(self,op)
#...
self.transformObjs(op,objList,rotVec,posVec)
def transformObjs(self,op,objList,rotVec,posVec) :
'''
op: my objectdata plugin
objList: polygon objects to be tansformed (linked in InExcludeList)
rotVec: rotation vector
posVec: position vector
'''
doc = op.GetDocument()
doc.StartUndo()
doc.AddUndo(c4d.UNDO_CHANGE,op)
parentList = []
for obj in objList:
doc.AddUndo(c4d.UNDO_CHANGE,obj)
#store parent for arranging back later
parentList.append(obj.GetUp())
objMg = obj.GetMg()
#arrange polygon objects under my object plugin
obj.InsertUnder(op)
obj.SetMg(objMg)
obj.Message(c4d.MSG_CHANGE) #i'm not sure this is nessesary
#transformed
op.SetAbsRot(rotVec)
op.SetAbsPos(posVec)
#arrange back to primary scene structure
for i,obj in enumerate(objList) :
doc.AddUndo(c4d.UNDO_CHANGE,obj)
objMgRot = obj.GetMg()
obj.InsertUnder(parentList _) _
_ obj.SetMg(objMgRot)
obj.Message(c4d.MSG_CHANGE)
doc.EndUndo()
#...
By this way, too many undos are created (every single value changed)
like in this post: https://plugincafe.maxon.net/topic/6978/7859_undo-in-plugin&KW=self.mouse_checker&PID=32593#32593
But is actual not the main issues.
The probleme is that i can`t set the polygon object and the controller object (my object plugin) back on the same undo step.
So it is not user friendly and they can make unknown mistakes very easily.
I hope, you can understand me by my bad english skills 
Thanks for any tips!
shirayuki