|
@@ -0,0 +1,124 @@
|
|
|
+/* ==============================================================================
|
|
|
+ * 功能描述:xyz坐标重叠检查
|
|
|
+ * 创 建 者:Garrett
|
|
|
+ * 创建日期:2018/10/23 15:08:55
|
|
|
+ * ==============================================================================*/
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using Autodesk.Revit.DB;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using SAGA.DotNetUtils.Others;
|
|
|
+using SAGA.RevitUtils;
|
|
|
+using SAGA.RevitUtils.Extends;
|
|
|
+
|
|
|
+namespace Saga.PlugIn.ModelCheck
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ [ParseIndex(Index = 13)]
|
|
|
+ class InstanceLocationOverlapCheck : ModeCheckBase
|
|
|
+ {
|
|
|
+ public InstanceLocationOverlapCheck()
|
|
|
+ {
|
|
|
+ Name = "xyz坐标重叠检查";
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool Check()
|
|
|
+ {
|
|
|
+ if (!RBase.IsRight)
|
|
|
+ {
|
|
|
+ IsRight = RBase.IsRight;
|
|
|
+ return IsRight;
|
|
|
+ }
|
|
|
+ IsRight = SubCheck();
|
|
|
+ return IsRight;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 族名称编码规范检查
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool SubCheck()
|
|
|
+ {
|
|
|
+ bool unitResult = true;
|
|
|
+ foreach (SagaSignCheckResult signResult in RBase.Results)
|
|
|
+ {
|
|
|
+ var doc = signResult.RDocument;
|
|
|
+ var instances = doc.GetFamilyInstances();
|
|
|
+ var groups = instances.GroupBy(t => t.GetLocationPoint(),new XyzEqualComparer(0.01d));
|
|
|
+ foreach (var group in groups)
|
|
|
+ {
|
|
|
+ var key = group.Key;
|
|
|
+ if(key==null)continue;
|
|
|
+ var list = group.ToList();
|
|
|
+ if(list.Count==1)continue;
|
|
|
+ var fi = list.FirstOrDefault();
|
|
|
+ var result = GetCheckResult(fi);
|
|
|
+ list.Remove(fi);
|
|
|
+ if (result == null) continue;
|
|
|
+
|
|
|
+ result.RMessage = $"与{string.Join(",", list.Select(t => t.Id.ToString()))}的坐标发生重叠,请检查";
|
|
|
+ Results.Add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Results.All(t => t.IsRight);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取检测结果
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="fi"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private InstanceLocationOverlapCheckResult GetCheckResult(Element fi)
|
|
|
+ {
|
|
|
+ var result = new InstanceLocationOverlapCheckResult(){IsRight = false};
|
|
|
+ result.Id = fi.Id.ToString();
|
|
|
+ result.FamilyName = fi.GetFamilyName();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //[DataCheckProcessAspect]
|
|
|
+ public override void Export()
|
|
|
+ {
|
|
|
+ // Check();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ IWorkbook book = DCRExport.GetWorkbook();
|
|
|
+ ISheet sheet = book.GetSheet(Name);
|
|
|
+
|
|
|
+ #region 添加数据
|
|
|
+ int index = 3;
|
|
|
+ foreach (InstanceLocationOverlapCheckResult result in Results)
|
|
|
+ {
|
|
|
+ //数量多过,只显示有问题的
|
|
|
+ if (result.IsRight) continue;
|
|
|
+
|
|
|
+ index++;
|
|
|
+ IRow rowN = sheet.CreateRow(index);
|
|
|
+ DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
|
|
|
+ int j = -1;
|
|
|
+ rowN.AddCell(++j, result.FamilyName, style);
|
|
|
+ rowN.AddCell(++j, result.Id, style);
|
|
|
+ string rowN4 = result.IsRight ? "通过" : "不通过";
|
|
|
+ rowN.AddCell(++j, rowN4, style);
|
|
|
+ rowN.AddCell(++j, result.RMessage, style);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageShowBase.Show(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ class InstanceLocationOverlapCheckResult : ModeCheckResultBase
|
|
|
+ {
|
|
|
+ public string FamilyName { get; set; }
|
|
|
+
|
|
|
+ public string Id { get; set; }
|
|
|
+ }
|
|
|
+}
|