Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        private static void CloseTransaction()
        {
            if (SteelTransaction != null)
            {
                SteelTransaction.Commit();
                SteelTransaction = null;
            }

            if (DocumentLocked == true)
            {
                DocumentLocked = DocumentManager.UnlockCurrentDocument();
                DocumentLocked = false;
            }
        }
Exemplo n.º 3
0
        public void LeaveContext(DocContext ctx)
        {
            if (SteelTransaction != null)
            {
                SteelTransaction.Commit();
                SteelTransaction = null;
            }

            if (DocumentLocked == true)
            {
                DocumentLocked = DocumentManager.UnlockCurrentDocument();
                DocumentLocked = false;
            }
        }
Exemplo n.º 4
0
        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");
            }
        }
Exemplo n.º 5
0
        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");
            }
        }