示例#1
0
        public void CreateAndInsert(Scheme scheme)
        {
            using (var t = db.TransactionManager.StartTransaction())
            {
                var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord;
                scale = AcadLib.Scale.ScaleHelper.GetCurrentAnnoScale(db);
                // Создание таблиц
                List <ObjectId> idsTable   = new List <ObjectId>();
                Point3d         ptCurTable = Point3d.Origin;
                foreach (var sec in scheme.Sections)
                {
                    Table table = getTable(sec);
                    table.Position = ptCurTable;
                    table.TransformBy(Matrix3d.Scaling(scale, table.Position));

                    ptCurTable = new Point3d(ptCurTable.X + table.Width + 25 * scale, ptCurTable.Y, 0);

                    cs.AppendEntity(table);
                    t.AddNewlyCreatedDBObject(table, true);
                    idsTable.Add(table.Id);
                }

                // Вставка таблиц
                DragSel.Drag(ed, idsTable.ToArray(), Point3d.Origin);
                t.Commit();
            }
        }
示例#2
0
        private void InsertTables(Table table)
        {
            using (var t = db.TransactionManager.StartTransaction())
            {
                var scale = 100; //AcadLib.Scale.ScaleHelper.GetCurrentAnnoScale(db);
                var cs    = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord;

                table.TransformBy(Matrix3d.Scaling(scale, table.Position));

                var ids = new List <ObjectId>();

                cs.AppendEntity(table);
                t.AddNewlyCreatedDBObject(table, true);
                ids.Add(table.Id);

                // Если нужны дополнительные таблицы - ВРС, Ведомость деталей
                Point3d ptNextTable = new Point3d(table.Position.X, table.Position.Y - table.Height - 10 * scale, 0);
                if (options.HasBillTable)
                {
                    Bill.BillService billService = new Bill.BillService(db, options.TableService.GetElementsForBill(blocks));
                    var billTable = billService.CreateTable();
                    billTable.Position = ptNextTable;
                    billTable.TransformBy(Matrix3d.Scaling(scale, billTable.Position));
                    cs.AppendEntity(billTable);
                    t.AddNewlyCreatedDBObject(billTable, true);
                    ids.Add(billTable.Id);

                    ptNextTable = new Point3d(billTable.Position.X, billTable.Position.Y - billTable.Height - 10 * scale, 0);
                }
                if (options.HasDetailTable)
                {
                    Details.DetailService detailService = new Details.DetailService(options.TableService.GetDetails(), db);
                    var idsDetails = detailService.CreateTable(ptNextTable);
                    ids.AddRange(idsDetails);
                }
                DragSel.Drag(ed, ids.ToArray(), Point3d.Origin);
                t.Commit();
            }
        }