public LayoutSheet AddLayout(string layoutName, PaperSize size)
        {
            using (Database template = new Database(false, true))
            {
                Transaction destTransaction = _document.TransactionManager.TopTransaction;
                SideLoad(template);
                //Database old = Application.DocumentManager.MdiActiveDocument.Database;

                Layout destinationLayout = destTransaction.GetObject(LayoutManager.Current.CreateLayout(layoutName), OpenMode.ForWrite) as Layout;
                //HostApplicationServices.WorkingDatabase = template;

                using (Transaction sourceTrans = template.TransactionManager.StartTransaction())
                {
                    //Layout layout = _document.Database.GetLayout(GetLayoutName(size));
                    Layout layout = template.GetLayout(GetLayoutName(size));
                    destinationLayout.CopyFrom(layout);
                    BlockTableRecord sourceBlockTableRecord =
                        sourceTrans.GetObject(layout.BlockTableRecordId, OpenMode.ForRead) as BlockTableRecord;
                    ObjectIdCollection sourceObjects = new ObjectIdCollection();
                    foreach (ObjectId objectId in sourceBlockTableRecord)
                    {
                        sourceObjects.Add(objectId);
                    }
                    IdMapping mapping = new IdMapping();
                    // TODO: Confirm ignore is correct option
                    _document.WblockCloneObjects(sourceObjects, destinationLayout.BlockTableRecordId, mapping, DuplicateRecordCloning.Ignore, false);
                }

                LayoutSheet resultSheet = new LayoutSheet(_logger, destinationLayout);
                Sheets.Add(resultSheet.Name, resultSheet);

                LayoutManager.Current.CurrentLayout = resultSheet.Name;
                Object acadObject = Application.AcadApplication;
                //Will this break in coreconsole?
                acadObject.GetType().InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, null, acadObject, null);

                return(resultSheet);
            }
        }
        public void Scan()
        {
            _logger.LogTrace($"Layout sheet controller scanning {_document.Filename}");
            Database acCurDb = _document;

            Transaction  acTrans = acCurDb.TransactionManager.TopTransaction;
            DBDictionary layouts = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary;

            // Step through and list each named layout and Model
            foreach (DBDictionaryEntry item in layouts)
            {
                if (!Sheets.ContainsKey(item.Key) && item.Key != "Model")
                {
                    _logger.LogTrace($"Sheet {item.Key} found");
                    Layout      acLayout = acTrans.GetObject(item.Value, OpenMode.ForRead) as Layout;
                    LayoutSheet ls       = new LayoutSheet(_logger, acLayout);

                    _logger.LogTrace($"Sheet {item.Key} added");
                    Sheets.Add(item.Key, ls);
                }
            }
        }