Undoing problem



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

    On 25/06/2004 at 16:16, xxxxxxxx wrote:

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

    ---------
    My plugin is creating an object, and making it child of another object. I need to make it support undo, so when undo is clicked, the new child is deleted.

        
        
        
        
           BaseDocument *doc = GetActiveDocument();  
           BaseObject *op = doc->GetActiveObject();
        
        
        
        
           BaseObject *child = BaseObject::Alloc(Onull);  
           doc->AddUndo(UNDO_NEW,child);
        
        
        
        
           doc->InsertObject(child,op,NULL,FALSE);
        
        
        
        
           doc->EndUndo();  
           doc->Message(MSG_UPDATE);
        
        
        
        
           DrawViews(NULL);
        
        
        
    

    That function, creates a null object, and inserts it under the active object.
    Pressing undo though, deletes the activeobject and not just the new child
     
    I'm not sure how undo's work in cinema yet, so im not fully sure whats happening.



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

    On 28/06/2004 at 01:06, xxxxxxxx wrote:

    UNDO_NEW needs to be called after the object has been inserted.



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

    On 28/06/2004 at 01:47, xxxxxxxx wrote:

    Forgive me, I didn't mean to put the UNDO_NEW before. Well I just tested it after the object was inserted and it still deletes the parent object to.
     
    This is the steps im taking
     
    1. Creating a cube
    2. Select the cube
    3. Select plugin menu item, which calls the above code (except with UNDO_NEW after the Insert)
    4. A new object is added as a child of the cube
    5. Click the undo button
    6. Both the cube and the child are deleted
     
    only the child should be deleted right?



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

    On 28/06/2004 at 01:53, xxxxxxxx wrote:

    Figured it out,
     
    I forgot to include doc->StartUndo() first


Log in to reply