Multiple Undos with different objects



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/02/2008 at 05:29, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.111 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    hi all.

    is it possible to have undos of various objects and the document in a single undo block between StartUndo() and EndUndo()?

    > doc->StartUndo(); \>      doc->AddUndo(UNDO_CHANGE, doc);   // no idea how to place this \>      Bool solo= solo_objects(doc, doc->GetFirstObject());   // function contains undos for objects \>      if(solo) doc->GetDataInstance()->GetContainerInstance(SOLO_ID)->SetLong(ID_SOLO_SET, solo); \>      else doc->GetDataInstance()->RemoveData(SOLO_ID); \>      EventAdd(); \>      doc->EndUndo(); \>

    in the code above i have that recursive solo_objects function with an AddUndo() for every object in the scene/object manager. this works fine, everything is undone as intended except for the change to the document. and it doesnt matter whether i put doc->AddUndo(UNDO_CHANGE, doc) before that solo_objects function or inside it, right before the doc is modified. so is it possible at all? btw the only thing i do with the doc is storing a subcontainer in the doc's container but after clicking UNDO the container in the doc is still there, unlike the containers and changes to all the objects - that works fine.
    i hope that was clear enough... thank you very much.

    Yakuza



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/02/2008 at 10:24, xxxxxxxx wrote:

    Move your StartUndo() and EndUndo() out of the recursion and everything inbetween will be treated as one undo. StartUndo()/EndUndo() represents a single undo step. Simple as that.

    Unfortunately, you can't do undos for the document itself. Only document items can have undos stored (objects, tags, materials, timeline elements, etc.).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/02/2008 at 14:33, xxxxxxxx wrote:

    hi Robert.

    thank you for your clarification, so it seems i got everything right. there were no start/endundo() calls in the recursive function, they embrace it (see above code) and that worked well except for the document. now that you confirmed undos do not work for the doc itself i dont need to waste time making it work and i guess my first c++ plugin is finished :D

    cheers
    Yakuza


Log in to reply