FinishTransaction
Namespace: Digi21.DigiNG
Assembly: Digi21.DigiNG.Plugin
Closes the most recent open transaction on the active drawing window's undo stack. A static method of DigiNG.
public static void FinishTransaction()
Exceptions
| Exception | When |
|---|---|
NullReferenceException |
No drawing window is open. |
Remarks
On closing, the transaction becomes the last closed transaction: the next UNDO command or DigiNG.Undo() call undoes its changes. A transaction without changes is discarded. If no transaction is open, the call closes nothing.
If automatic vertex insertion at intersections when finishing a line is enabled, before closing the transaction Digi3D.AI inserts vertices into lines intersecting those added in the transaction.
A command does not need to call this method: Digi3D.AI closes the transaction when the command ends. Use this method in two cases:
- To close a transaction opened through NewTransaction
(false). - To modify the drawing file from code running outside a command, for example a panel button handler. If the code does not open and close a transaction, changes remain in an open transaction that
UNDOdoes not undo. The code opens a transaction throughNewTransaction(false)before the changes and closes it throughFinishTransaction()afterward.
See "Undo transactions" in DigiNG for how transactions work.
Example
This method deletes entities from a panel button handler, outside any command. The deletion belongs to a closed transaction that the user undoes through UNDO:
using Digi21.DigiNG;
using Digi21.DigiNG.Entities;
namespace Ejemplos;
public static class AccionesPanel
{
public static void EliminaEntidades(IEnumerable<Entity> entidades)
{
DigiNG.NewTransaction(false);
try
{
DigiNG.DrawingFile.Delete(entidades);
}
finally
{
DigiNG.FinishTransaction();
}
}
}