Enables or disables the recording of operations on objects.

syntaxSyntax:
DlxPage.EnableUndo(enable, reset = true)

Parameters

Parameter Description
enable Specify true to enable recording of operations performed on objects or false to disable it.
reset Specify true to clear the undo stack.

Return Value

If the operation ends correctly, it returns true otherwise it returns false.

Remarks

If the undo is disabled, the entire undo stack is reset.

Example

  Copy codeCopy code
var prj = DlxApp.GetJob().GetProject("Example Sch");
if (!prj.IsValid())
  prj = DlxApp.GetJob().NewProject("Example Sch");
var doc = prj.GetDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
if (!doc.IsValid())
{
  doc = prj.NewDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
  doc.SetPageFormat("A4", false);
}
if (doc.IsValid() && doc.Activate())
{
  var page = doc.GetActivePage();
  if (page.IsValid())
  {
    var layer = page.GetLayerFromType(DlxApp.LAYERTYPE_DRAWING);
    if (layer.IsValid())
    {
      page.EnableUndo(false);
      // non-cancelable operations.
      layer.DrawLine(new DlxPoint(50,50), new DlxPoint(50,70));
      layer.DrawLine(new DlxPoint(50,70), new DlxPoint(75,80));
      layer.DrawLine(new DlxPoint(75,80), new DlxPoint(100,70));
      layer.DrawLine(new DlxPoint(100,70), new DlxPoint(100,50));
      layer.DrawLine(new DlxPoint(100,50), new DlxPoint(50,50));
      layer.DrawLine(new DlxPoint(50,50), new DlxPoint(50,50));

      page.EnableUndo(true);
      // cancelable operations.
      layer.DrawLine(new DlxPoint(50,70), new DlxPoint(100,70));
    }
  }
}

See also