Explorar o código

mxg:添加Revit族参数完整性检查

mengxiangge %!s(int64=6) %!d(string=hai) anos
pai
achega
e560727d42

+ 2 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -366,6 +366,8 @@
     </Compile>
     <Compile Include="ToolsData\ModeCheck\EquipReferSystemCheck.cs" />
     <Compile Include="ToolsData\ModeCheck\EquipReferSystemCheckResult.cs" />
+    <Compile Include="ToolsData\ModeCheck\ParameterIntegrityCheck.cs" />
+    <Compile Include="ToolsData\ModeCheck\ParameterIntegrityCheckResult.cs" />
     <Compile Include="ToolsData\ModeCheck\ModeCheckBase.cs" />
     <Compile Include="ToolsData\ModeCheck\DataCheckRule.cs" />
     <Compile Include="ToolsData\CheckBase\DCElementType.cs" />

+ 143 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/ParameterIntegrityCheck.cs

@@ -0,0 +1,143 @@
+/* ==============================================================================
+ * 功能描述:Revit族参数完整性检查
+ * 创 建 者: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;
+using SAGA.DotNetUtils.Extend;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Common;
+using SAGA.MBI.Tools;
+using SAGA.MBI.ToolsData.CheckBase;
+using SAGA.RevitUtils.Extends;
+using SAGA.RevitUtils.MEP;
+
+namespace SAGA.MBI.ToolsData.ModeCheck
+{
+    /// <summary>
+    /// UnitCheck
+    /// </summary>
+    class ParameterIntegrityCheck : ModeCheckBase
+    {
+        public ParameterIntegrityCheck()
+        {
+            Name = "Revit族参数完整性检查";
+        }
+
+        [DataCheckProcessAspect]
+        public override bool Check()
+        {
+            if (!RBase.IsRight)
+            {
+                IsRight = RBase.IsRight;
+                return IsRight;
+            }
+            IsRight = FamilyNameCodeCheck();
+            return IsRight;
+        }
+
+        public override void Correct()
+        {
+            throw new NotImplementedException();
+        }
+        /// <summary>
+        /// 族名称编码规范检查
+        /// </summary>
+        /// <returns></returns>
+        private bool FamilyNameCodeCheck()
+        {
+            bool unitResult = true;
+            var list = new List<ParameterIntegrityCheckResult>();
+            foreach (SagaSignCheckResult signResult in RBase.Results)
+            {
+                var doc = signResult.RDocument;
+                var instances = doc.GetFamilyInstances();
+                var mbiItems = instances.Where(t => t.IsEquipment() || t.IsEquipmentPart()).ToList();
+                var familyGroups = mbiItems.GroupBy(t => t.GetFamily().Name);
+                foreach (IGrouping<string, FamilyInstance> familyGroup in familyGroups)
+                {
+                    string familyName = familyGroup.Key;
+                    FamilyInstance fi = familyGroup.FirstOrDefault();
+                    var result = GetCheckResult(fi);
+                    if (result == null) continue;
+                    result.FamilyName = familyName;
+                    result.RBase = signResult;
+                    list.Add(result);
+                }
+            }
+            return Results.All(t => t.IsRight);
+        }
+        /// <summary>
+        /// 获取检测结果
+        /// </summary>
+        /// <param name="fi"></param>
+        /// <returns></returns>
+        private ParameterIntegrityCheckResult GetCheckResult(FamilyInstance fi)
+        {
+            var result = new ParameterIntegrityCheckResult(){IsRight = true};
+            var localNameParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalName);
+            var localIdParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalID);
+            result.Id = fi.Id.ToString();
+            List<string> list=new List<string>();
+            if(localIdParameter==null)
+                list.Add(RevitBuiltInParameter.EquipLocalID);
+            if(localNameParameter==null)
+                list.Add(RevitBuiltInParameter.EquipLocalName);
+            if (list.Count > 0)
+            {
+                result.IsRight = false;
+                result.RMessage = $"缺失的参数为:{string.Join("、", list)}";
+            }
+            return result;
+        }
+
+        //[DataCheckProcessAspect]
+        public override void Export()
+        {
+            //   Check();
+            try
+            {
+                IWorkbook book = DCRExport.GetWorkbook();
+                ISheet sheet = book.GetSheet(Name);
+
+                #region 添加数据
+                int index = 3;
+                foreach (ParameterIntegrityCheckResult result in Results)
+                {
+                    SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
+                    if (rbase == null)
+                        continue;
+                    //数量多过,只显示有问题的
+                    if (result.IsRight) continue;
+                 
+                    index++;
+                    IRow rowN = sheet.CreateRow(index);
+                    DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
+                    int c = 0;
+                    rowN.AddCell(c++, rbase.RFloorName, style);
+                    rowN.AddCell(c++, rbase.RFileName, style);
+                    rowN.AddCell(c++, rbase.RPath, style);
+                    rowN.AddCell(c++, result.FamilyName, style);
+                    rowN.AddCell(c++, result.Id, style);
+                    string rowN4 = result.IsRight ? "通过" : "不通过";
+                    rowN.AddCell(c++, rowN4, style);
+                    rowN.AddCell(c++, result.RMessage, style);
+                }
+
+                #endregion
+
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+        }
+    }
+}

+ 30 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/ParameterIntegrityCheckResult.cs

@@ -0,0 +1,30 @@
+/* ==============================================================================
+ * 功能描述:Revit参数完整性检查结果 
+ * 创 建 者:Garrett
+ * 创建日期:2018/10/23 15:13:17
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+using SAGA.MBI.ToolsData.CheckBase;
+
+namespace SAGA.MBI.ToolsData.ModeCheck
+{
+    /// <summary>
+    /// UnitCheckResult
+    /// </summary>
+    [Serializable]
+    class ParameterIntegrityCheckResult : ModeCheckResultBase
+    {
+        public string FamilyName { get; set; }
+        
+        public string Id { get; set; }
+        public override void Export()
+        {
+            base.Export();
+        }
+    }
+}