On 20/10/2015 at 16:40, xxxxxxxx wrote:
Hi,
I'm running into an issue w/ UNDOTYPE_CHANGE. The documentation says it should be used for:
Any change to an object, including hierarchy modifications; modification in positioning (object has been moved from A to B), substructures etc. (Needs to be called BEFORE action.)
However, it doesn't seem to respect Hierarchy changes where the object is removed from the hierarchy and reinserted somewhere else.
"""Place Under Null
Places the first selected object under a Null located at the world origin.
"""
import c4d
from c4d import gui
def main() :
#Remove the Selected Object
doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
op.Remove()
#Create a Null, and place selected under it
null_obj = c4d.BaseObject(c4d.Onull)
op.InsertUnder(null_obj)
#Add null to scene
doc.InsertObject(null_obj)
doc.AddUndo(c4d.UNDOTYPE_NEW,null_obj)
#Tell C4D something has changed
doc.EndUndo()
c4d.EventAdd()
if __name__=='__main__':
main()
To Recreate:
1. Add a cube to your scene
2. Run the above script, your Cube will be placed under a Null
3. Hit Undo (Null is removed, you just have your Cube again)
4. Hit Redo - You get your cube under the null, and a copy of your cube!
Using "c4d.UNDOTYPE_DELETE" seems to resolve the issue, but I'm curious to know why UNDOTYPE_CHANGE doesn't work as described.