예제 #1
0
        public PanelBase(Panel panelXml, BaseService service, MountingPanel panelMount = null)
        {
            Panel = panelXml;
             Service = service;

             MarkWithoutElectric = AkrHelper.GetMarkWithoutElectric(Panel.mark);

             Length = panelXml.gab.length;
             Height = panelXml.gab.height;

             XMinContour = 0;
             XMaxContour = Length;

             XMinPanel = 0;
             XMaxPanel = Length;
             LengthByTiles = Length;

             Thickness = getThickness (panelXml, panelMount);

             setNLayerPanel();
             IsOL = Panel.mark.StartsWith("ол", StringComparison.OrdinalIgnoreCase);
             IsUpperStoreyPanel = defineIsUpperStoreyPanel();

             HasWindows = Panel.windows?.window?.Count() > 0;
        }
예제 #2
0
 public FloorArchitect(BlockReference blRefArPlan, BaseService service)
 {
     Service = service;
      IdBlRef = blRefArPlan.Id;
      IdBtr = blRefArPlan.BlockTableRecord;
      BlName = blRefArPlan.Name;
      // определение параметров плана и окон
      try
      {
     definePlanNumberAndSection(blRefArPlan);
      }
      catch (Exception ex)
      {
     Inspector.AddError($"Ошибка при определении параметров арх.плана {BlName}.", blRefArPlan, icon: System.Drawing.SystemIcons.Error);
      }
      // определение окон в плане
      Windows = defineWindows(blRefArPlan);
 }
        public void GetAllPlanesTest()
        {
            List<FloorArchitect> floorsAr;
             string testFile = @"c:\temp\test\АКР\Base\Tests\Тест-ПостроениеФасада.dwg";

             using (var db = new Database(false, true))
             {
            db.ReadDwgFile(testFile, FileOpenMode.OpenForReadAndAllShare, false, "");
            db.CloseInput(true);
            using (AcadLib.WorkingDatabaseSwitcher dbSwitcher = new AcadLib.WorkingDatabaseSwitcher(db))
            {
               BaseService baseService = new BaseService();
               baseService.InitToCreationPanels(db);

               floorsAr = FloorArchitect.GetAllPlanes(db, baseService);
            }
            db.SaveAs(@"c:\temp\test\АКР\Base\Tests\Тест-ПостроениеФасада-WindowMarks.dwg", DwgVersion.Current);
             }

             Assert.AreEqual(floorsAr.Count, 2);
        }
 public BlockSectionHorizontal(string blName, BaseService service)
     : base(blName, service)
 {
 }
 public BlockSectionVertical(string blName, BaseService service)
     : base(blName, service)
 {
 }
예제 #6
0
 public void Init()
 {
     baseService = new BaseService();
      // считывание Xml базы панелей
      baseService.ReadPanelsFromBase();
 }
예제 #7
0
        /// <summary>
        /// Поиск архитектурных планов в Модели.
        /// Запускает транзакцию.
        /// </summary>            
        public static List<FloorArchitect> GetAllPlanes(Database db, BaseService service)
        {
            List<FloorArchitect> floorsAr = new List<FloorArchitect>();

             using (var t = db.TransactionManager.StartTransaction())
             {
            var ms = SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject( OpenMode.ForRead) as BlockTableRecord;
            foreach (ObjectId idEnt in ms)
            {
               var blRefArPlan = idEnt.GetObject(OpenMode.ForRead, false, true) as BlockReference;
               if (blRefArPlan == null) continue;

               if (blRefArPlan.Name.StartsWith(Settings.Default.BlockPlaneArchitectPrefixName, StringComparison.CurrentCultureIgnoreCase))
               {
                  FloorArchitect floorAr = new FloorArchitect(blRefArPlan, service);
                  floorsAr.Add(floorAr);
               }
            }
            t.Commit();
             }
             return floorsAr;
        }
      /// <summary>
      /// Копирование блоков сечений из шаблона блоков и доп списка блоков blNames
      /// </summary>
      /// <param name="fileBlocksTemplate"></param>
      /// <param name="service"></param>
      /// <param name="blNames"></param>
      /// <returns></returns>
      public static List<BlockSectionAbstract> LoadSections(string fileBlocksTemplate, BaseService service, List<string> blNames, 
            out Dictionary<string, ObjectId> blNamesCopy)
      {
         blNamesCopy = new Dictionary<string, ObjectId>();
         Dictionary<ObjectId, BlockSectionAbstract> blSecToCopy = new Dictionary<ObjectId, BlockSectionAbstract>();         
         using (var dbBlocks = new Database(false, true))
         {
            dbBlocks.ReadDwgFile(fileBlocksTemplate, FileOpenMode.OpenForReadAndAllShare, false, "");
            dbBlocks.CloseInput(true);
            using (var bt = dbBlocks.BlockTableId.Open(OpenMode.ForRead) as BlockTable)
            {
               foreach (ObjectId idBtr in bt)
               {
                  using (var btr = idBtr.Open(OpenMode.ForRead) as BlockTableRecord)
                  {
                     var blNameToCopy = blNames.Find(n => n.Equals(btr.Name, StringComparison.OrdinalIgnoreCase));
                     if (!string.IsNullOrEmpty(blNameToCopy))
                     {
                        blNamesCopy.Add(blNameToCopy, btr.Id);
                        continue;
                     }                     

                    BlockSectionAbstract blSec = null;
                     if (btr.Name.StartsWith(Settings.Default.BlockPanelSectionVerticalPrefixName, StringComparison.OrdinalIgnoreCase))
                     {
                        blSec = new BlockSectionVertical(btr.Name, service);
                     }
                     else if (btr.Name.StartsWith(Settings.Default.BlockPanelSectionHorizontalPrefixName, StringComparison.OrdinalIgnoreCase))
                     {
                        blSec = new BlockSectionHorizontal(btr.Name, service);
                     }

                     if (blSec != null)
                     {
                        var resParse = blSec.ParseBlName();
                        if (resParse.Success)
                        {
                           blSecToCopy.Add(idBtr, blSec);
                           //Определение ассоциативных штриховок и объектов с которыми они связаны
                           blSec.getHatchAssociateIds(btr);                           
                        }
                        else
                        {
                           Inspector.AddError($"Не определены параметры блока сечения в файле шаблона блоков. {btr.Name}. {resParse.Error}",
                              icon: System.Drawing.SystemIcons.Error);
                        }
                     }
                  }
               }
            }
            if (blSecToCopy.Count > 0)
            {
               using (ObjectIdCollection ids = new ObjectIdCollection(blSecToCopy.Keys.ToArray()))
               {
                  foreach (var item in blNamesCopy.Values)
                  {
                     ids.Add(item);
                  }

                  using (IdMapping map = new IdMapping())
                  {
                     service.Db.WblockCloneObjects(ids, service.Db.BlockTableId, map, DuplicateRecordCloning.Replace, false);
                     foreach (var item in blSecToCopy)
                     {
                        item.Value.IdBtr = map[item.Key].Value;
                        if (item.Value._hatchsAssociatedIdsDictInTemplate != null)
                        {
                           item.Value.setHatchIdsMapping(map);
                           //item.Value.ReplaceAssociateHatch();
                        }
                     }
                     foreach (var name in blNames)
                     {
                        ObjectId idBl;
                        if (blNamesCopy.TryGetValue(name, out idBl))
                        {
                           blNamesCopy[name] = map[idBl].Value;
                        }
                     }
                  }
               }              
            }
            else
            {
               Inspector.AddError("Не найдены блоки сечений панелей в файле шаблона блоков АКР. " +
                  $"Файл шаблона {fileBlocksTemplate}. Префикс блоков {Settings.Default.BlockPanelSectionVerticalPrefixName} " +
                  $"и {Settings.Default.BlockPanelSectionHorizontalPrefixName}", icon: System.Drawing.SystemIcons.Error);
            }
         }
         return blSecToCopy.Values.ToList();         
      }
 public BlockSectionAbstract(string blName, BaseService service)
 {
    BlName = blName;
    Service = service;
 }
예제 #10
0
 public CreatePanelsBtrEnvironment(BaseService service)
 {
     _service = service;
 }
 public CreatePanelsBtrEnvironment(BaseService service)
 {
     _service = service;
 }
예제 #12
0
 public BaseServiceTests()
 {
     baseService = new BaseService();
      baseService.ReadPanelsFromBase();
      doc = Application.DocumentManager.MdiActiveDocument;
 }