123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /* ==============================================================================
- * 功能描述:SagaCheck
- * 创 建 者:Garrett
- * 创建日期:2019/6/11 16:09:09
- * ==============================================================================*/
- using System;
- using System.Linq;
- using Autodesk.Revit.DB;
- using SAGA.RevitUtils.Extends;
- using ServiceRevitLib.Extend;
- using ServiceRevitLib.Mode;
- using ServiceRevitLib.Utils;
- namespace ServiceRevitLib.DataCheck.Mode
- {
- /// <summary>
- /// SagaCheck
- /// </summary>
- class FamilyNameCheck : CheckBase
- {
- public FamilyNameCheck()
- {
- ReferenceSheet = "参考-revit分类";
- }
- public override void Check()
- {
- try
- {
- base.Check();
- #region
- var ccategories = DataCheckRule.GetCodeCheckCategories();
- var categories = m_Doc.Settings.Categories;
- foreach (DCR_CodeCheckCategory ccategory in ccategories)
- {
- try
- {
- var category = categories.get_Item(ccategory.Name);
- if (category == null) continue;
- BuiltInCategory builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
- var elements = m_Doc.GetElements<FamilyInstance>(builtInCategory);
- var groupByFamily = elements.GroupBy(t => t.GetFamilyName());
- foreach (IGrouping<string, FamilyInstance> grouping in groupByFamily)
- {
- var subElements = grouping.ToList();
- var subElement = subElements.FirstOrDefault();
- if (subElement is FamilyInstance fi)
- {
- var result = new FamilyNameCheckResult();
- result.FamilyName = grouping.Key;
- if (fi.IsEquipment() || fi.IsEquipmentPart() || fi.IsBeacon())
- {
- result.Result = ResultState.Success;
- }
- else
- {
- result.Result = ResultState.Failure;
- result.ResultMsg = "请检查族名称编码是否符合要求";
- }
- Content.Add(result);
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- }
- #endregion
- }
- catch (Exception e)
- {
- Result = ResultState.Failure;
- ResultMsg = $"{e.Message}\r\n{e.StackTrace}";
- }
-
- }
-
- }
- }
|