123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /* ==============================================================================
- * 功能描述:设备部件定位点和中心点对比检查
- * 创 建 者:Garrett
- * 创建日期:2018/10/23 15:08:55
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using NPOI.SS.UserModel;
- using SAGA.DotNetUtils.Others;
- using SAGA.MBI.DataArrange;
- using SAGA.MBI.Tools;
- using SAGA.MBI.ToolsData.CheckBase;
- using SAGA.RevitUtils.Extends;
- namespace SAGA.MBI.ToolsData.ModeCheck
- {
- /// <summary>
- /// UnitCheck
- /// </summary>
- class EquipmentLocationCenterComparer : ModeCheckBase
- {
- public EquipmentLocationCenterComparer()
- {
- Name = "设备定位点检查";
- }
- [DataCheckProcessAspect]
- public override bool Check()
- {
- if (!RBase.IsRight)
- {
- IsRight = RBase.IsRight;
- return IsRight;
- }
- IsRight = GetCheckResult();
- return IsRight;
-
- }
- public override void Correct()
- {
- throw new NotImplementedException();
- }
- private bool GetCheckResult()
- {
- bool unitResult = true;
- foreach (SagaSignCheckResult signResult in RBase.Results)
- {
- var document = signResult.RDocument;
- var elements = document.GetFamilyInstances();
- var equips = elements.Where(t => t.IsEquipmentPart()||t.IsEquipment());
- foreach (FamilyInstance fi in equips)
- {
- var result = GetCheckResult(fi);
- result.RBase = signResult;
- Results.Add(result);
- }
- }
- return Results.All(t => t.IsRight);
- }
- /// <summary>
- /// 获取检测结果
- /// </summary>
- /// <param name="fi"></param>
- /// <returns></returns>
- private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
- {
- var result = new EquipmentPartRefEqCheckResult();
- result.FamilyName = fi.GetFamily().Name;
- result.Id = fi.Id.ToString();
- XYZ location = fi.GetLocationPoint();
- XYZ origin = fi.GetBoxCenter();
- if (location.IsEqual2(origin))
- {
- result.IsRight = true;
- }
- else
- {
- result.IsRight = false;
- result.RMessage = "定位点和中心点不重合,请检查";
- }
- result.LocationXYZ = location.ToString2D();
- result.CenterXYZ = origin.ToString2D();
- return result;
- }
- //[DataCheckProcessAspect]
- public override void Export()
- {
- // Check();
- try
- {
- IWorkbook book = DCRExport.GetWorkbook();
- //ISheet sheet = book.CreateSheet(Name);
- ISheet sheet = book.GetSheet(Name);
- #region 添加数据
- int index = 3;
- //IRow row4 = sheet.CreateRow(index);
- //row4.HeightInPoints = 15;
- //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
- //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
- //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
- //row4.AddCell(3, "族名称", DataCheckNPOIStyle.Title);
- //row4.AddCell(4, "ID", DataCheckNPOIStyle.Title);
- //row4.AddCell(4, "定位点", DataCheckNPOIStyle.Title);
- //row4.AddCell(4, "中心点", DataCheckNPOIStyle.Title);
- //row4.AddCell(5, "通过", DataCheckNPOIStyle.Title);
- //row4.AddCell(6, "备注(失败原因)", DataCheckNPOIStyle.Title);
- foreach (EquipmentPartRefEqCheckResult result in Results)
- {
- SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
- if (rbase == null)
- continue;
- index++;
- IRow rowN = sheet.CreateRow(index);
- DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
- int i = 0;
- rowN.AddCell(i++, rbase.RFloorName, style);
- rowN.AddCell(i++, rbase.RFileName, style);
- rowN.AddCell(i++, rbase.RPath, style);
- rowN.AddCell(i++, result.FamilyName, style);
- rowN.AddCell(i++, result.Id, style);
- rowN.AddCell(i++, result.LocationXYZ, style);
- rowN.AddCell(i++, result.CenterXYZ, style);
- string rowN4 = result.IsRight ? "通过" : "不通过";
- rowN.AddCell(i++, rowN4, style);
- rowN.AddCell(i++, result.RMessage, style);
- }
- #endregion
- }
- catch (Exception e)
- {
- MessageShowBase.Show(e);
- }
- }
- }
- }
|