Creating Undo for points

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

On 20/12/2006 at 17:23, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   9.x 
Platform:      Mac OSX  ; 
Language(s) :   C.O.F.F.E.E  ;

---------
I want to store the current state of an object for Undo purposes. But I would only like to store its current points location (its a polygon object). Using doc->AddUndo(UNDO_OBJECT_BASEDATA,op) or doc->AddUndo(UNDO_OBJECT,op) doesn't seem to work :(
Anyone knows how to do this?

Rui Batista

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

On 29/12/2006 at 02:17, xxxxxxxx wrote:

Here a little working example for adding Undo when modifying points.

  
MyMenuPlugin::Execute(doc)  
{  
       // Called when the menu item is chosen  
  
       // TODO: Do whatever you want  
       var op = doc->GetActiveObject();  
       if(!op || !instanceof(op,PolygonObject)) return TRUE;  
         
       var pcnt = op->GetPointCount();  
       if(pcnt == 0) return TRUE;  
         
       var points = op->GetPoints();  
       if(!points) return FALSE;  
         
       var index;  
     for (index=0; index<pcnt; index++)  
     {  
          points[index].y = points[index].y + 100;  
     }  
  
     doc->StartUndo();  
     doc->AddUndo(UNDO_OBJECT_BASEDATA,op);  
  
     op->SetPoints(points);  
     op->Message(MSG_UPDATE);  
       
     doc->EndUndo();  
       
     EventAdd();  
       
     return TRUE;       
}  

hope this helps

cheers,
Matthias