public void BuildBeam() { List <ObjectId> objectIds = getLineIds(); using (Transaction tr = db.TransactionManager.StartTransaction()) { List <Line> lines = objectIds.Select(id => id.GetObject(OpenMode.ForRead) as Line).ToList(); Autodesk.AdvanceSteel.DocumentManagement.DocumentManager.LockCurrentDocument(); using (Autodesk.AdvanceSteel.CADAccess.Transaction steelTr = Autodesk.AdvanceSteel.CADAccess.TransactionManager.StartTransaction()) { foreach (Line line in lines) { if (fields.Any(row => row.Layer == line.Layer)) { CSVField row = fields.First(r => r.Layer == line.Layer); createBeam(row, line); } } steelTr.Commit(); } Autodesk.AdvanceSteel.DocumentManagement.DocumentManager.UnlockCurrentDocument(); tr.Commit(); } }
private static void CloseTransaction() { if (SteelTransaction != null) { SteelTransaction.Commit(); SteelTransaction = null; } if (DocumentLocked == true) { DocumentLocked = DocumentManager.UnlockCurrentDocument(); DocumentLocked = false; } }
public void LeaveContext(DocContext ctx) { if (SteelTransaction != null) { SteelTransaction.Commit(); SteelTransaction = null; } if (DocumentLocked == true) { DocumentLocked = DocumentManager.UnlockCurrentDocument(); DocumentLocked = false; } }
private static void StartTransaction() { if (DocumentLocked == false) { DocumentLocked = DocumentManager.LockCurrentDocument(); } if (SteelTransaction == null && DocumentLocked == true) { SteelTransaction = Autodesk.AdvanceSteel.CADAccess.TransactionManager.StartTransaction(); } if (DocumentLocked == false || SteelTransaction == null) { throw new System.Exception("Failed to access Document"); } }
public void EnsureInContext(DocContext ctx) { if (SteelTransaction != null || DocumentLocked == true) { throw new System.Exception("Nested context"); } DocumentLocked = DocumentManager.LockCurrentDocument(); if (DocumentLocked == true) { SteelTransaction = Autodesk.AdvanceSteel.CADAccess.TransactionManager.StartTransaction(); } if (DocumentLocked == false || SteelTransaction == null) { throw new System.Exception("Failed to access Document"); } }
public CADContext() { bDocumentLocked = DocumentManager.LockCurrentDocument(); if (bDocumentLocked == true) { tr = Autodesk.AdvanceSteel.CADAccess.TransactionManager.StartTransaction(); if (tr != null) { bTransactionStarted = true; } } if (bDocumentLocked == false || bTransactionStarted == false) { UnInitialize(); throw new System.Exception("Failed to access AutoCAD Document"); } }