Browse Source

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

xulisong 6 years ago
parent
commit
383f1e813e
32 changed files with 605 additions and 1861 deletions
  1. 303 282
      MBI/SAGA.DotNetUtils/Geometry/Geometry2d.cs
  2. 1 1
      MBI/SAGA.MBI/Calc/CalcContext.cs
  3. 7 7
      MBI/SAGA.MBI/Calc/ObjectCalc.cs
  4. 4 1
      MBI/SAGA.MBI/Common/MBIConst.cs
  5. 3 3
      MBI/SAGA.MBI/DataArrange/DalBeacon.cs
  6. 21 44
      MBI/SAGA.MBI/DataArrange/DalCommon.cs
  7. 3 3
      MBI/SAGA.MBI/DataArrange/DalEquip.cs
  8. 9 9
      MBI/SAGA.MBI/DataArrange/DalEquipPart.cs
  9. 0 17
      MBI/SAGA.MBI/DataArrange/DalMatchFM.cs
  10. 14 0
      MBI/SAGA.MBI/Extend/DocExtend.cs
  11. 80 29
      MBI/SAGA.MBI/Extend/ElementExtend.cs
  12. 1 1
      MBI/SAGA.MBI/Model/MBeacon.cs
  13. 5 5
      MBI/SAGA.MBI/TestCommand.cs
  14. 63 11
      MBI/SAGA.MBI/ToolCommand.cs
  15. 8 10
      MBI/SAGA.MBI/ToolsData/CheckEquipCategory.cs
  16. 5 5
      MBI/SAGA.MBI/ToolsData/CheckEquipInSpace.cs
  17. 2 2
      MBI/SAGA.MBI/ToolsData/CopyLocalNameValue.cs
  18. 5 5
      MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheck.cs
  19. 1 1
      MBI/SAGA.MBI/ToolsData/ModeCheck/ColumnCheck.cs
  20. 12 11
      MBI/SAGA.MBI/ToolsData/ModeCheck/ConnectorCheck.cs
  21. 16 19
      MBI/SAGA.MBI/ToolsData/ModeCheck/ElementRangeCheck.cs
  22. 13 13
      MBI/SAGA.MBI/ToolsData/ModeCheck/EquipReferSystemCheck.cs
  23. 4 4
      MBI/SAGA.MBI/ToolsData/ModeCheck/EquipmentInSpaceCheck.cs
  24. 4 4
      MBI/SAGA.MBI/ToolsData/ModeCheck/EquipmentPartRefEqCheck.cs
  25. 2 2
      MBI/SAGA.MBI/ToolsData/ModeCheck/FamilyNameCheck.cs
  26. 5 5
      MBI/SAGA.MBI/ToolsData/ModeCheck/ParameterIntegrityCheck.cs
  27. 3 3
      MBI/SAGA.MBI/ToolsData/UpdateRelationEquipinSpace.cs
  28. 1 1
      MBI/SAGA.MBI/WinView/BeModingDutyList/MEquipNoMode.cs
  29. 1 1
      MBI/SAGA.RevitUtils/Extends/FamilyInstanceExtend.cs
  30. 9 0
      MBI/SAGA.RevitUtils/Extends/WallExtend.cs
  31. 0 1361
      MBI/SAGA.RevitUtils/Geometry/Geometry2D.cs
  32. 0 1
      MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

File diff suppressed because it is too large
+ 303 - 282
MBI/SAGA.DotNetUtils/Geometry/Geometry2d.cs


+ 1 - 1
MBI/SAGA.MBI/Calc/CalcContext.cs

@@ -250,7 +250,7 @@ namespace SAGA.MBI.Calc
                     if (elem != null)
                     {
                         mode.Type = elem.GetType().Name;
-                        mode.Family = elem.GetFamily()?.Name;
+                        mode.Family = elem.GetFamilyName();
                         mode.Category = elem.GetCategory().ToString();
                     }
                 }

+ 7 - 7
MBI/SAGA.MBI/Calc/ObjectCalc.cs

@@ -76,9 +76,9 @@ namespace SAGA.MBI.Calc
         /// <param name="context"></param>
         private static void CalcEquipPartRlt_Simple(CalcContext context)
         {
-            var familyInstances = context.RevitDoc.GetFamilyInstances();
-            List<FamilyInstance> parts = new List<FamilyInstance>();
-            foreach (FamilyInstance fi in familyInstances)
+            var elements = context.RevitDoc.GetMbiElements();
+            List<Element> parts = new List<Element>();
+            foreach (Element fi in elements)
             {
                 if (!fi.IsValidObject) continue;
                 if (fi.IsEquipment())
@@ -164,10 +164,10 @@ namespace SAGA.MBI.Calc
         /// <param name="context"></param>
         private static void CalcEquipPartRlt(CalcContext context)
         {
-            var familyInstances = context.RevitDoc.GetFamilyInstances();
+            var familyInstances = context.RevitDoc.GetMbiElements();
             var rspaces = context.RevitDoc.GetSpaces().Where(t => t.IsValidObject).ToList();
-            List<FamilyInstance> parts = new List<FamilyInstance>();
-            foreach (FamilyInstance fi in familyInstances)
+            List<Element> parts = new List<Element>();
+            foreach (Element fi in familyInstances)
             {
                 if (!fi.IsValidObject) continue;
                 if (fi.IsEquipment())
@@ -213,7 +213,7 @@ namespace SAGA.MBI.Calc
                 }
             }
             //单独处理部件,因为部件要依赖设备
-            foreach (FamilyInstance fi in parts)
+            foreach (Element fi in parts)
             {
                 // 在这里处理部件 
                 MEquipmentPart equipment = DalEquipPart.GetEquipPart(fi);

+ 4 - 1
MBI/SAGA.MBI/Common/MBIConst.cs

@@ -31,7 +31,10 @@ namespace SAGA.MBI.Common
         public static readonly string EmptyFilePath = Path.Combine(MBIResourcePath, "EmptyFile\\EmptyProject.rvt");
         public static readonly string BeaconFamilyFilePath = Path.Combine(AppBaseInfo.FamilyPath, "Beacon.rfa");
         public static readonly string SpaceTagFamilyFilePath = Path.Combine(AppBaseInfo.FamilyPath, "空间标记.rfa");
-
+        /// <summary>
+        /// 幕墙编码
+        /// </summary>
+        public static readonly string CurtainWallCode = "CWPN";
         //访问数据的地址
         public static string SaasLocalHost
         {

+ 3 - 3
MBI/SAGA.MBI/DataArrange/DalBeacon.cs

@@ -33,7 +33,7 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MBeacon GetBeaconQueryId(FamilyInstance elem)
+        public static MBeacon GetBeaconQueryId(Element elem)
         {
             MBeacon mode = GetBeacon(elem);
             if (mode == null) return null;
@@ -48,14 +48,14 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MBeacon GetBeacon(FamilyInstance elem)
+        public static MBeacon GetBeacon(Element elem)
         {
             if (!elem.IsBeacon()) return null;
             var floorId= elem.Document.PathName.GetFileName();
             var bimId = elem.GetCloudBIMId();
             MBeacon mode = new MBeacon(floorId,bimId);
             mode.FMID = elem.GetParameterString("点位标签ID");
-            mode.PreviewImage = elem.GetFamily().GetPreviewImage(new System.Drawing.Size(200, 200));
+            mode.PreviewImage = elem.GetFamilyImage();
             mode.FloorId = elem.Document.PathName.GetFileName();
             return mode;
         }

+ 21 - 44
MBI/SAGA.MBI/DataArrange/DalCommon.cs

@@ -45,28 +45,17 @@ namespace SAGA.MBI.DataArrange
             {
                 equipment = DalSpace.GetSpaceQueryId(elem);
             }
-            else
+            else if (elem.IsEquipment())
             {
-                if (elem is FamilyInstance fi)
-                {
-                    //信标
-                    if (fi.IsBeacon())
-                    {
-                        equipment = DalBeacon.GetBeaconQueryId(fi);
-                    }
-                    else
-                    {
-                        string familyCode = fi.GetFamilyCode();
-                        //Code的位数为4,判定为设备,6位是部件
-                        if (familyCode.IsNotNullEmptyExt())
-                        {
-                            if (fi.IsEquipment())
-                                equipment = DalEquip.GetEquipmentnQueryId(fi);
-                            else if (fi.IsEquipmentPart())
-                                equipment = DalEquipPart.GetEquipPartQueryId(fi);
-                        }
-                    }
-                }
+                equipment = DalEquip.GetEquipmentnQueryId(elem);
+            }
+            else if (elem.IsEquipmentPart())
+            {
+                equipment = DalEquipPart.GetEquipPartQueryId(elem);
+            }
+            else if (elem.IsBeacon())
+            {
+                equipment = DalBeacon.GetBeaconQueryId(elem);
             }
 
             return equipment ?? GetDefaultEquipBase(elem);
@@ -87,29 +76,17 @@ namespace SAGA.MBI.DataArrange
             }
             else
             {
-                if (elem is FamilyInstance fi)
+                //信标
+                if (elem.IsBeacon())
                 {
-                    //信标
-                    if (fi.IsBeacon())
-                    {
-                        equipment = DalBeacon.GetBeacon(fi);
-                    }
-                    else
-                    {
-                        string familyCode = fi.GetFamilyCode();
-                        //Code的位数为4,判定为设备,6位是部件
-                        if (familyCode.IsNotNullEmptyExt())
-                        {
-                            MEquipmentFamily family = CommonTool.GetEquipFamily(familyCode);
-                            if (family != null)
-                            {
-                                if (fi.IsEquipment())
-                                    equipment = DalEquip.GetEquipment(fi);
-                                else if (fi.IsEquipmentPart())
-                                    equipment = DalEquipPart.GetEquipPart(fi);
-                            }
-                        }
-                    }
+                    equipment = DalBeacon.GetBeacon(elem);
+                }
+                else
+                {
+                    if (elem.IsEquipment())
+                        equipment = DalEquip.GetEquipment(elem);
+                    else if (elem.IsEquipmentPart())
+                        equipment = DalEquipPart.GetEquipPart(elem);
                 }
             }
             return equipment;
@@ -191,7 +168,7 @@ namespace SAGA.MBI.DataArrange
             if (bySubsetQuerys.Any())
             {
                 //通过subset_query查询的数据,空间,业务空间
-                list.AddRange(CommonConvert.FloorQuery_SubSet(floorId,bySubsetQuerys));
+                list.AddRange(CommonConvert.FloorQuery_SubSet(floorId, bySubsetQuerys));
             }
 
             return list;

+ 3 - 3
MBI/SAGA.MBI/DataArrange/DalEquip.cs

@@ -32,7 +32,7 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MEquipment GetEquipmentnQueryId(FamilyInstance elem)
+        public static MEquipment GetEquipmentnQueryId(Element elem)
         {
             MEquipment mode = GetEquipment(elem);
             if (mode == null) return null;
@@ -46,7 +46,7 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MEquipment GetEquipment(FamilyInstance elem)
+        public static MEquipment GetEquipment(Element elem)
         {
             if (!elem.IsEquipment()) return null;
             string familyCode = elem.GetFamilyCode();
@@ -57,7 +57,7 @@ namespace SAGA.MBI.DataArrange
             MEquipment mode = new MEquipment(floorId, bimid);
             mode.EquipClassCode = familyCode;
             mode.Family = family;
-            mode.PreviewImage = elem.GetFamily().GetPreviewImage(new System.Drawing.Size(200, 200));
+            mode.PreviewImage = elem.GetFamilyImage();
             //从模型中读取的信息点
             mode.ReadRevitParamter(elem);
             //model.BIMType = familyName + ";" + typeName;

+ 9 - 9
MBI/SAGA.MBI/DataArrange/DalEquipPart.cs

@@ -29,7 +29,7 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MEquipmentPart GetEquipPartQueryId(FamilyInstance elem)
+        public static MEquipmentPart GetEquipPartQueryId(Element elem)
         {
             MEquipmentPart mode = GetEquipPart(elem);
             if (mode == null) return null;
@@ -43,7 +43,7 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static MEquipmentPart GetEquipPart(FamilyInstance elem)
+        public static MEquipmentPart GetEquipPart(Element elem)
         {
             if (!elem.IsEquipmentPart()) return null;
             string familyCode = elem.GetFamilyCode();
@@ -54,7 +54,7 @@ namespace SAGA.MBI.DataArrange
             MEquipmentPart mode = new MEquipmentPart(floorId, bimid);
             mode.EquipClassCode = familyCode;
             mode.Family = family;
-            mode.PreviewImage = elem.GetFamily().GetPreviewImage(new System.Drawing.Size(200, 200));
+            mode.PreviewImage = elem.GetFamilyImage();
             //获取部件关联的设备
             mode.MEquipment = DalEquipPart.GetPartParentElement(elem);
             //这里处理从设备中读取到的数据
@@ -72,15 +72,15 @@ namespace SAGA.MBI.DataArrange
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        public static MEquipment GetPartParentElement(FamilyInstance fi)
+        public static MEquipment GetPartParentElement(Element element)
         {
-            Document doc = fi.Document;
-            string family = fi.GetFamily().Name.Substring(0, 4);
+            string code = element.GetFamilyCode();
+            if (code.IsNullOrEmpty()) return null;
             //构件所关联的设备
-            var parentInst = doc.GetElements(new ElementIntersectsElementFilter(fi))
-                .FirstOrDefault(t => t is FamilyInstance && !t.Id.IsEqual(fi.Id) && t.GetFamilyCode() == family);
+            var parentInst = element.Document.GetElements(new ElementIntersectsElementFilter(element))
+                .FirstOrDefault(t =>  !t.Id.IsEqual(element.Id) && t.GetFamilyCode() == code);
             if (parentInst == null) return null;
-            var equip = DalEquip.GetEquipment(parentInst as FamilyInstance);
+            var equip = DalEquip.GetEquipment(parentInst);
             return equip;
         }
     }

+ 0 - 17
MBI/SAGA.MBI/DataArrange/DalMatchFM.cs

@@ -37,35 +37,19 @@ namespace SAGA.MBI.DataArrange
         /// <returns></returns>
         public static List<MMissFMEquip> GetMissFmEquips(string floorId)
         {
-            Log4Net.Debug("开始:获取缺少FM的设备");
             List<MMissFMEquip> list = new List<MMissFMEquip>();
             /* 1,查找楼层下的所有设备(FamilyInstance)
              * 2,批量传入BimId,查询岗位
              * 3,判断资产是否存在;
             */
            
-            var doc = ExternalDataWrapper.Current.Doc;
-            if (doc == null) return list;
             try
             {
-                Log4Net.Debug("开始:下载当前层所有的设备,部件");
                 List<MRevitEquipBase> equipments = DalCommon.DownLoadCouldData(floorId,new []{"Eq","Ec"});
-                Log4Net.Debug("结束:下载当前层所有的设备,部件");
                 foreach (var equip in equipments)
                 {
                     if (equip.FMID.IsNullOrEmpty())
                     {
-                        var revitId = equip.BimID.GetBIMID();
-                        var fi = doc.GetElement(revitId) as FamilyInstance;
-                        if (fi == null) continue;
-                        //未匹配资产,只识别设备和部件
-                        if (!fi.IsEquipment() && !fi.IsEquipmentPart()) continue;
-                        string familyCode = fi.GetFamilyCode();
-                        //Code的位数为4,判定为设备,6位是部件
-                        if (familyCode.IsNullOrEmptyExt()) continue;
-                        MEquipmentFamily family = CommonTool.GetEquipFamily(familyCode);
-                        equip.EquipClassCode = familyCode;
-                        equip.Family = family;
                         list.Add(new MMissFMEquip(equip));
                     }
                 }
@@ -74,7 +58,6 @@ namespace SAGA.MBI.DataArrange
             {
                 MessageShowBase.Show(e);
             }
-            Log4Net.Debug("结束:获取缺少FM的设备");
             //MessageShowBase.Infomation(st.Elapsed.ToString());
             return list;
         }

+ 14 - 0
MBI/SAGA.MBI/Extend/DocExtend.cs

@@ -140,5 +140,19 @@ namespace SAGA.MBI.Tools
                 fs.Activate();
             return fs;
         }
+
+        /// <summary>
+        /// 获取所有的Docment中,岗位对象
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <param name="bic"></param>
+        /// <returns></returns>
+        public static List<Element> GetMbiElements(this Document doc)
+        {
+            List<Element> elements=new List<Element>();
+            elements.AddRange(doc.GetElements(typeof(Wall)));
+            elements.AddRange(doc.GetElements(typeof(FamilyInstance)));
+            return elements;
+        }
     }
 }

+ 80 - 29
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -5,6 +5,7 @@
  * ==============================================================================*/
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
@@ -31,20 +32,38 @@ namespace SAGA.MBI.Tools
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        public static bool IsEquipment(this FamilyInstance fi)
+        public static bool IsEquipment(this Element element)
         {
-            var family = fi.GetFamily().Name;
-            return Regex.IsMatch(family, @"^[A-Z]{4}\s*-\s*\S*");
+            bool result = false;
+            if (element is Wall wall)
+            {//添加幕墙识别
+                result = wall.WallType.Kind == WallKind.Curtain;
+
+            }
+            else
+            if (element is FamilyInstance fi)
+            {
+                var family = fi.GetFamilyName();
+                result = Regex.IsMatch(family, @"^[A-Z]{4}\s*-\s*\S*");
+            }
+
+            return result;
         }
         /// <summary>
         /// 判断是否为设备部件 设备族为6位
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        public static bool IsEquipmentPart(this FamilyInstance fi)
+        public static bool IsEquipmentPart(this Element element)
         {
-            var family = fi.GetFamily().Name;
-            return Regex.IsMatch(family, @"^[A-Z]{6}\s*-\s*\S*");
+            bool result = false;
+            if (element is FamilyInstance fi)
+            {
+                var family = fi.GetFamilyName();
+                result = Regex.IsMatch(family, @"^[A-Z]{6}\s*-\s*\S*");
+            }
+
+            return result;
         }
         /// <summary>
         /// 设备mbi设备名称解析
@@ -63,10 +82,10 @@ namespace SAGA.MBI.Tools
         /// </summary>
         /// <param name="elem"></param>
         /// <returns></returns>
-        public static bool IsBeacon(this FamilyInstance elem)
+        public static bool IsBeacon(this Element elem)
         {
-            var family = elem.GetFamily().Name;
-            return (Regex.IsMatch(family, MBIConst.BeaconFamilyName));
+            var family = elem.GetFamilyName();
+            return family != null && (Regex.IsMatch(family, MBIConst.BeaconFamilyName));
         }
 
         /// <summary>
@@ -171,38 +190,70 @@ namespace SAGA.MBI.Tools
         /// 族名称的命名规则:ATFC-风机盘管
         /// </summary>
         /// <returns></returns>
-        public static string GetFamilyCode(this Element fi)
+        public static string GetFamilyCode(this Element element)
         {
             string code = "";
-            string familyName = fi.GetFamily()?.Name;
-            if (familyName == null) return code;
-            //族名称的命名规则:ATFC-风机盘管
-            int index = familyName.IndexOf('-');
-            if (index != -1 && index + 1 != familyName.Length)
-                code = familyName.Substring(0, familyName.IndexOf('-'));
-            //移除前面和后面的空格
-            return code.Trim();
+            if (element is FamilyInstance fi)
+            {
+                string familyName = fi.GetFamilyName();
+                if (familyName == null) return code;
+                //族名称的命名规则:ATFC-风机盘管
+                int index = familyName.IndexOf('-');
+                if (index != -1 && index + 1 != familyName.Length)
+                    code = familyName.Substring(0, familyName.IndexOf('-'));
+                //移除前面和后面的空格
+                code = code.Trim();
+            }
+            else if (element is Wall wall)
+            {
+                if (wall.IsCurtaiWall())
+                    code = MBIConst.CurtainWallCode;
+            }
+
+            return code;
+        }
+
+        public static string GetFamilyName(this Element element)
+        {
+            return element.GetFamily()?.Name;
+        }
+        /// <summary>
+        /// 获取族的缩略图
+        /// </summary>
+        /// <param name="element"></param>
+        /// <returns></returns>
+        public static Bitmap GetFamilyImage(this Element element)
+        {
+            return element.GetFamily()?.GetPreviewImage(new System.Drawing.Size(200, 200));
         }
         /// <summary>
         /// 获取关联的空间
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        public static Space GetReferenceSpace(this FamilyInstance fi, List<Space> spaces = null)
+        public static Space GetReferenceSpace(this Element element, List<Space> spaces = null)
         {
-            Space space = fi.Space;
-            if (space != null) return space;
-            if (spaces == null)
-                spaces = fi.Document.GetSpaces().Where(t => t.IsValidObject).ToList();
-            var origin1 = fi.GetLocationPointMBIXYZ();
-            foreach (Space tempSpace in spaces)
+            Space space = null;
+            if (element is FamilyInstance fi)
             {
-                //没有Space属性,取定位点,判断定位点所在空间
-                if (tempSpace.IsPointInSpace(origin1))
+                space = fi.Space;
+                if (space != null) return space;
+                if (spaces == null)
+                    spaces = fi.Document.GetSpaces().Where(t => t.IsValidObject).ToList();
+                var origin1 = fi.GetLocationPointMBIXYZ();
+                foreach (Space tempSpace in spaces)
                 {
-                    space = tempSpace;
-                    break;
+                    //没有Space属性,取定位点,判断定位点所在空间
+                    if (tempSpace.IsPointInSpace(origin1))
+                    {
+                        space = tempSpace;
+                        break;
+                    }
                 }
+            }else if (element is Wall wall)
+            {
+                if (wall.IsCurtaiWall())
+                    space = null;
             }
 
             return space;

+ 1 - 1
MBI/SAGA.MBI/Model/MBeacon.cs

@@ -92,7 +92,7 @@ namespace SAGA.MBI.Model
                 Element elem = ExternalDataWrapper.Current.Doc.GetElement(bimId);
                 if (elem == null) return;
                 //获取预览图
-                this.PreviewImage = elem.GetFamily().GetPreviewImage(new System.Drawing.Size(200, 200));
+                this.PreviewImage = elem.GetFamilyImage();
                 WinModeInfoMaintenance win = WinModeInfoMaintenance.GetWindow();
                 win.Show(this);
             }

+ 5 - 5
MBI/SAGA.MBI/TestCommand.cs

@@ -76,10 +76,10 @@ namespace SAGA.MBI
 
                 var doc = commandData.View.Document;
                 var spaces = doc.GetSpaces().Where(t => t.IsValidObject).ToList();
-                var fis = doc.GetFamilyInstances().Where(t => t.IsEquipmentPart() || t.IsEquipment());
+                var fis = doc.GetMbiElements().Where(t => t.IsEquipmentPart() || t.IsEquipment());
                 List<List<List<XYZ>>> spaceVertexes = spaces.Select(t => t.GetBoundaryVertexes()).ToList();
-                List<KeyValuePair<FamilyInstance, XYZ>> keyValuePairs = fis.Select(t => new KeyValuePair<FamilyInstance, XYZ>(t, t.GetLocationPointMBIXYZ())).ToList();
-                List<KeyValuePair<FamilyInstance, XYZ>> keyValuePairs_bak = new List<KeyValuePair<FamilyInstance, XYZ>>();
+                List<KeyValuePair<Element, XYZ>> keyValuePairs = fis.Select(t => new KeyValuePair<Element, XYZ>(t, t.GetLocationPointMBIXYZ())).ToList();
+                List<KeyValuePair<Element, XYZ>> keyValuePairs_bak = new List<KeyValuePair<Element, XYZ>>();
                 long rtime = 0, gtime = 0;
                 int rcount = 0, gcount = 0;
                 Stopwatch watch = new Stopwatch();
@@ -87,7 +87,7 @@ namespace SAGA.MBI
                 watch.Start();
                 foreach (var pair in keyValuePairs)
                 {
-                    FamilyInstance fi = pair.Key;
+                    Element fi = pair.Key;
                     var space = fi.GetReferenceSpace(spaces);
                     if (space != null)
                     {
@@ -119,7 +119,7 @@ namespace SAGA.MBI
                         double maxz = spaceVertex.Max(t => t.Z);
                         //if (z.IsBetween(minz, maxz))
                         {
-                            if(Geometry2D.InSidePolygon(spaceVertex.Count,spaceVertex.Select(t=>t.ToPointD()).ToArray(),point)!=2)
+                            if(Geometry2D.InSidePolygon(spaceVertex.Select(t=>t.ToPointD()).ToArray(),point)!=2)
                             //if (xyz.PointInPolygonByRay(spaceVertex) != -1)
                             {
                                 gcount++;

+ 63 - 11
MBI/SAGA.MBI/ToolCommand.cs

@@ -16,6 +16,7 @@ using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using FWindSoft.DataFramework;
 using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Geometry;
 using SAGA.DotNetUtils.Logger;
 using SAGA.DotNetUtils.Others;
 using SAGA.MBI.Common;
@@ -37,7 +38,7 @@ namespace SAGA.MBI
 {
 
     #region 工具
-    
+
     /// <summary>
     /// 立管对齐
     /// </summary>
@@ -50,7 +51,7 @@ namespace SAGA.MBI
             try
             {
                 int count = 0;
-                WinSelectCheckFloors win =new WinSelectCheckFloors();
+                WinSelectCheckFloors win = new WinSelectCheckFloors();
                 if (win.ShowDialog() == true)
                 {
                     VerticalPipeAlign.Instance.Execute();
@@ -87,15 +88,15 @@ namespace SAGA.MBI
                 switch (tip)
                 {
                     case DialogResult.Yes:
-                        count=DelZeroSpace.OperateAll();
+                        count = DelZeroSpace.OperateAll();
                         break;
                     case DialogResult.No:
-                        count=DelZeroSpace.OperateCurFloor();
+                        count = DelZeroSpace.OperateCurFloor();
                         break;
                     default:
                         break;
                 }
-                if(tip== DialogResult.Yes||tip== DialogResult.No)
+                if (tip == DialogResult.Yes || tip == DialogResult.No)
                     MessageShowBase.Infomation($"此次操作共删除{count}个空间");
 
             }
@@ -123,9 +124,60 @@ namespace SAGA.MBI
         {
             try
             {
-                var fi = ExternalDataWrapper.Current.UiApp.GetSelectedElement() as FamilyInstance;
+                List<Geometry2D.PointD> newPoints = new List<Geometry2D.PointD>();
+                newPoints.Add(new Geometry2D.PointD(0, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 400));
+                newPoints.Add(new Geometry2D.PointD(200, 200));
+                newPoints.Add(new Geometry2D.PointD(0, 400));
+
+                //外点 ==2
+                var testPoint = new Geometry2D.PointD(-100, 200);
+                int flag = Geometry2D.InSidePolygon( newPoints.ToArray(),testPoint ); 
+                //==0
+                var testPoint2 = new Geometry2D.PointD(50, 200);
+                int flag2 = Geometry2D.InSidePolygon(newPoints.ToArray(), testPoint2);
+
+                List<Geometry2D.PointD> newPoints3 = new List<Geometry2D.PointD>();
+                newPoints3.Add(new Geometry2D.PointD(0, 0));
+                newPoints3.Add(new Geometry2D.PointD(400, 0));
+                newPoints3.Add(new Geometry2D.PointD(400, 200));
+                newPoints3.Add(new Geometry2D.PointD(200, 200));
+                newPoints3.Add(new Geometry2D.PointD(150, 200));
+                newPoints3.Add(new Geometry2D.PointD(100, 200));
+                newPoints3.Add(new Geometry2D.PointD(50, 200));
+                newPoints3.Add(new Geometry2D.PointD(0, 400));
+                //内点==0
+                var testPointI3 = new Geometry2D.PointD(25, 200);
+                int flagI3 = Geometry2D.InSidePolygon(newPoints3.ToArray(), testPointI3);
+                //外点==2
+                var testPointO3 = new Geometry2D.PointD(-25, 200);
+                int flagO3 = Geometry2D.InSidePolygon(newPoints3.ToArray(), testPointO3);
+
+                var fi = commandData.Application.PickElement("请选择图元") as FamilyInstance;
+                if (fi == null) return Result.Succeeded;
                 var space = fi.GetReferenceSpace();
-                MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}");
+                string str = "", str2 = "";
+                do
+                {
+                    if (space != null)
+                    {
+                        List<XYZ> spaceVertex = space.GetBoundaryVertexes().FirstOrDefault();
+                        if (spaceVertex == null)
+                        {
+                            str = "Boundary 为Null";
+                            break;
+                        }
+
+                        var xyz = fi.GetLocationPointMBIXYZ();
+                        str = "Geometry Intersection Result:" + xyz.PointInPolygonByRay(spaceVertex);
+
+                        str2 = "Geometry2D Intersection Result:" + Geometry2D.InSidePolygon(
+                                   spaceVertex.Select(t => t.ToPointD()).ToArray(), xyz.ToPointD());
+                    }
+
+                } while (false);
+                MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}" + "\r\n" + $"{str}" + "\r\n" + $"{str2}");
             }
             catch (Exception e)
             {
@@ -541,7 +593,7 @@ namespace SAGA.MBI
     [Regeneration(RegenerationOption.Manual)]
     public class AddSiSpaceCommand : ExternalCommand
     {
-       
+
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             List<string> errorIds = new List<string>();
@@ -578,12 +630,12 @@ namespace SAGA.MBI
                                 }
                             }
                         }
-                       
+
                     }
-                    MessageBox.Show("总共修改:"+totalIds.Count);
+                    MessageBox.Show("总共修改:" + totalIds.Count);
                     if (errorIds.Any()) ;
                     {
-                        MessageBox.Show("错误Ids:" + string.Join(";",errorIds));
+                        MessageBox.Show("错误Ids:" + string.Join(";", errorIds));
                     }
                 }
             }

+ 8 - 10
MBI/SAGA.MBI/ToolsData/CheckEquipCategory.cs

@@ -109,15 +109,15 @@ namespace SAGA.MBI.ToolsData
                 int bimid = cBimId.GetBIMID();
                 Element elem = doc.GetElement(bimid);
                 if (elem == null) continue;
-                FamilyInstance fi = elem as FamilyInstance;
-                if (fi == null) continue;
-                var code = fi.GetFamilyCode();
+                //FamilyInstance fi = elem as FamilyInstance;
+                //if (fi == null) continue;
+                var code = elem.GetFamilyCode();
                 var cCode = mode.EquipClassCode;
                 if (code != cCode)
                 {
                     delcontext.MEquipments.Add(mode);
 
-                    MEquipment equip = DalEquip.GetEquipment(fi);
+                    MEquipment equip = DalEquip.GetEquipment(elem);
                     if (equip == null) continue;
                     //暂时保留本地名称和本地编码
                  DalUploadFloor.SetSavePropertyValue(equip,mode);
@@ -125,7 +125,7 @@ namespace SAGA.MBI.ToolsData
                     addContext.MEquipments.Add(equip);
 
                     //识别设备所在空间
-                    var space = fi.GetReferenceSpace(spaces);
+                    var space = elem.GetReferenceSpace(spaces);
                     if (space == null) continue;
                     string spaceId = space.GetCloudBIMId();
                     MISpace mSpace = addContext.MSpaces.FirstOrDefault(t => t.BimID == spaceId);
@@ -146,22 +146,20 @@ namespace SAGA.MBI.ToolsData
                 int bimid = cBimId.GetBIMID();
                 Element elem = doc.GetElement(bimid);
                 if (elem == null) continue;
-                FamilyInstance fi = elem as FamilyInstance;
-                if (fi == null) continue;
-                var code = fi.GetFamilyCode();
+                var code = elem.GetFamilyCode();
                 var cCode = mode.EquipClassCode;
                 if (code != cCode)
                 {
                     delcontext.MEquipmentParts.Add(mode);
 
-                    MEquipmentPart equipment = DalEquipPart.GetEquipPart(fi);
+                    MEquipmentPart equipment = DalEquipPart.GetEquipPart(elem);
                     if (equipment == null) continue;
                     equipment.Operator = DocumentChangedOperator.Add;
                     //暂时保留本地名称和本地编码
                     DalUploadFloor.SetSavePropertyValue(equipment, mode);
                     addContext.MEquipmentParts.Add(equipment);
                     //识别设备所在空间
-                    var space = fi.GetReferenceSpace(spaces);
+                    var space = elem.GetReferenceSpace(spaces);
                     if (space == null) continue;
                     string spaceId = space.GetCloudBIMId();
                     MISpace mSpace = addContext.MSpaces.FirstOrDefault(t => t.BimID == spaceId);

+ 5 - 5
MBI/SAGA.MBI/ToolsData/CheckEquipInSpace.cs

@@ -62,7 +62,7 @@ namespace SAGA.MBI.ToolsData
             foreach (var equipment in context.MEquipments)
             {
                 var bimId = equipment.BimID;
-                FamilyInstance fi=document.GetElement(bimId.GetBIMID()) as FamilyInstance;
+                Element fi=document.GetElement(bimId.GetBIMID());
                 if (fi != null)
                 {
                     var space = fi.GetReferenceSpace(rspaces);
@@ -111,10 +111,10 @@ namespace SAGA.MBI.ToolsData
         /// <param name="context"></param>
         private static void CalcEquipPartRlt(CalcContext context)
         {
-            var linkElements = context.RevitDoc.GetFamilyInstances();
+            var linkElements = context.RevitDoc.GetMbiElements();
             var rspaces = context.RevitDoc.GetSpaces();
             //过滤出的所有实体
-            foreach (FamilyInstance fi in linkElements)
+            foreach (Element fi in linkElements)
             {
                 if (fi.IsEquipment())
                 {
@@ -126,7 +126,7 @@ namespace SAGA.MBI.ToolsData
                     var space = fi.GetReferenceSpace(rspaces);
                     if (space == null)
                     {
-                        string familyName = fi.GetFamily().Name;
+                        string familyName = fi.GetFamilyName();
                         var id = fi.Id.ToString();
                         equipment.EquipClassCode = familyName;
                         equipment.BimID = id;
@@ -146,7 +146,7 @@ namespace SAGA.MBI.ToolsData
                     var space = fi.GetReferenceSpace(rspaces);
                     if (space == null)
                     {
-                        string familyName = fi.GetFamily().Name;
+                        string familyName = fi.GetFamilyName();
                         var id = fi.Id.ToString();
                         part.EquipClassCode = familyName;
                         part.BimID = id;

+ 2 - 2
MBI/SAGA.MBI/ToolsData/CopyLocalNameValue.cs

@@ -71,7 +71,7 @@ namespace SAGA.MBI.ToolsData
                     trans.Start();
                     try
                     {
-                        var fis = doc.GetFamilyInstances();
+                        var fis = doc.GetMbiElements();
                         foreach (var fi in fis)
                         {
                             if (fi.IsEquipment() || fi.IsEquipmentPart())
@@ -107,7 +107,7 @@ namespace SAGA.MBI.ToolsData
         /// </summary>
         /// <param name="fi"></param>
         /// <returns>True成功,False失败</returns>
-        private static bool CopyProperty(FamilyInstance fi, bool isBackupValue = false)
+        private static bool CopyProperty(Element fi, bool isBackupValue = false)
         {
             bool result = false;
             try

+ 5 - 5
MBI/SAGA.MBI/ToolsData/DataCheck/DutyModeCodeDiffCheck.cs

@@ -1,5 +1,5 @@
 /* ==============================================================================
- * 功能描述:岗位和资产信息点一致性检查
+ * 功能描述:
  * 创 建 者:Garrett
  * 创建日期:2018/10/23 15:08:55
  * ==============================================================================*/
@@ -82,9 +82,9 @@ namespace SAGA.MBI.ToolsData.DataCheck
                     string cBimId = mode.BimID;
                     if (cBimId.IsNullOrEmpty()) continue;
                     int bimid = cBimId.GetBIMID();
-                    FamilyInstance fi = doc.GetElement(bimid) as FamilyInstance;
-                    if (fi == null) continue;
-                    var code = fi.GetFamilyCode();
+                    Element element = doc.GetElement(bimid);
+                    if (element == null) continue;
+                    var code = element.GetFamilyCode();
                     var cCode = mode.EquipClassCode;
                     if (code != cCode)
                     {
@@ -94,7 +94,7 @@ namespace SAGA.MBI.ToolsData.DataCheck
                         result.BIMID = bimid.ToString();
                         result.DCode = cCode;
                         result.MCode = code;
-                        result.FamilyName = fi.GetFamily()?.Name;
+                        result.FamilyName = element.GetFamilyName();
                         result.IsRight = false;
                         result.RMessage = "模型族编码与岗位设备类编码不一致,请检查模型是否需要更新或使用“族编码同步”命令同步";
                         list.Add(result);

+ 1 - 1
MBI/SAGA.MBI/ToolsData/ModeCheck/ColumnCheck.cs

@@ -68,7 +68,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
         {
             var result = new ColumnCheckResult();
-            result.FamilyName = fi.GetFamily().Name;
+            result.FamilyName = fi.GetFamilyName();
             result.Id = fi.Id.ToString();
             var roomBoundaries = fi.GetParameterInteger(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
             if (roomBoundaries ==1)

+ 12 - 11
MBI/SAGA.MBI/ToolsData/ModeCheck/ConnectorCheck.cs

@@ -69,13 +69,13 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         private List<ModeCheckResultBase> Check(SagaSignCheckResult signResult)
         {
             List<ModeCheckResultBase> list = new List<ModeCheckResultBase>();
-            var familyInstances = signResult.RDocument.GetFamilyInstances();
+            var elements = signResult.RDocument.GetMbiElements();
 
-            foreach (FamilyInstance fi in familyInstances)
+            foreach (var element in elements)
             {
-                if (fi.IsEquipment() || fi.IsEquipmentPart())
+                if (element.IsEquipment() || element.IsEquipmentPart())
                 {
-                    var result = GetCheckResult(fi);
+                    var result = GetCheckResult(element);
                     if (result == null) continue;
                     result.RBase = signResult;
                     list.Add(result);
@@ -119,18 +119,19 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
+        private ModeCheckResultBase GetCheckResult(Element element)
         {
+            if (element == null) return null;
             var result = new ConnectorCheckResult();
-            var code = fi.GetFamilyCode();
+            var code = element.GetFamilyCode();
             var defineConType = GetDefineConType(code);
             if (defineConType == null) return null;
-            result.FamilyName = fi.GetFamily().Name;
+            result.FamilyName = element.GetFamilyName();
             result.Type = code.Length == 4 ? DCElementType.Equipment : DCElementType.EuipmentPart;
-            result.Id = fi.Id.ToString();
+            result.Id = element.Id.ToString();
             result.IsRight = true;
-            CheckConType(result, fi,defineConType.Item1);
-            CheckConType(result,fi, defineConType.Item2);
+            CheckConType(result, element, defineConType.Item1);
+            CheckConType(result, element, defineConType.Item2);
             return result;
         }
         /// <summary>
@@ -154,7 +155,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="result"></param>
         /// <param name="domain"></param>
-        private void CheckConType(ConnectorCheckResult result,FamilyInstance fi, Domain domain)
+        private void CheckConType(ConnectorCheckResult result,Element fi, Domain domain)
         {
             if (domain != Domain.DomainUndefined)
             {

+ 16 - 19
MBI/SAGA.MBI/ToolsData/ModeCheck/ElementRangeCheck.cs

@@ -176,7 +176,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         {
             var result = new ElementRangeCheckResult();
             result.RBase = signResult;
-            result.FamilyName = element.GetFamily()?.Name;
+            result.FamilyName = element.GetFamilyName();
             result.Id = element.Id.ToString();
             try
             {
@@ -195,19 +195,28 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     zb = wall.GetBaseStaticHeight();
                     zt = wall.GetTopStaticHeight();
                 }
-                else if (element is FamilyInstance fi)
+                else if (element.IsSpace())
+                {
+                    var space = element as Space;
+                    isBoxInst = true;
+                    result.RType = DCElementType.Space;
+                    zb = space.GetBaseStaticHeight();
+                    zt = space.GetTopStaticHeight();
+                }
+                else 
                 {
-                    if (fi.IsAllColumn())
+                    if (element.IsAllColumn())
                     {
+                        var fi = element as FamilyInstance;
                         isBoxInst = true;
                         result.RType = DCElementType.Column;
                         zb = fi.GetBaseStaticHeight();
                         zt = fi.GetTopStaticHeight();
                     }
-                    else if (fi.IsEquipment() || fi.IsEquipmentPart() || fi.IsBeacon())
+                    else if (element.IsEquipment() || element.IsEquipmentPart() || element.IsBeacon())
                     {
-                        result.RType = GetRType(fi);
-                        zb = fi.GetLocationPointMBIXYZ().Z;
+                        result.RType = GetRType(element);
+                        zb = element.GetLocationPointMBIXYZ().Z;
                         rb = zb.IsBetween(hb, ht);
                         result.IsRight = rb;
                         result.RMessage = result.IsRight ? "" : "构件范围不满足要求;请检查构件位置";
@@ -217,18 +226,6 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                         result = null;
                     }
                 }
-                else if (element.IsSpace())
-                {
-                    var space = element as Space;
-                    isBoxInst = true;
-                    result.RType = DCElementType.Space;
-                    zb = space.GetBaseStaticHeight();
-                    zt = space.GetTopStaticHeight();
-                }
-                else
-                {
-                    result = null;
-                }
                 if (isBoxInst)
                 {
                     rb = zb.IsBetween(hb - w, hb);
@@ -257,7 +254,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private DCElementType GetRType(FamilyInstance fi)
+        private DCElementType GetRType(Element fi)
         {
             DCElementType name = DCElementType.None;
             if (fi.IsEquipment())

+ 13 - 13
MBI/SAGA.MBI/ToolsData/ModeCheck/EquipReferSystemCheck.cs

@@ -65,13 +65,13 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         private List<ModeCheckResultBase> Check(SagaSignCheckResult signResult)
         {
             List<ModeCheckResultBase> list = new List<ModeCheckResultBase>();
-            var familyInstances = signResult.RDocument.GetFamilyInstances();
+            var elements = signResult.RDocument.GetMbiElements();
 
-            foreach (FamilyInstance fi in familyInstances)
+            foreach (Element element in elements)
             {
-                if (fi.IsEquipment() || fi.IsEquipmentPart())
+                if (element.IsEquipment() || element.IsEquipmentPart())
                 {
-                    var result = GetCheckResult(fi);
+                    var result = GetCheckResult(element);
                     if (result == null) continue;
                     result.RBase = signResult;
                     list.Add(result);
@@ -85,17 +85,17 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
+        private ModeCheckResultBase GetCheckResult(Element element)
         {
             var result = new EquipReferSystemCheckResult();
-            var code = fi.GetFamilyCode();
+            var code = element.GetFamilyCode();
             var referSystems = GetReferSystems(code);
             if (referSystems.Count == 0) return null;
 
-            result.FamilyName = fi.GetFamily().Name;
-            result.Id = fi.Id.ToString();
+            result.FamilyName = element.GetFamilyName();
+            result.Id = element.Id.ToString();
 
-            var tuple = CheckConType(fi, referSystems);
+            var tuple = CheckConType(element, referSystems);
             result.IsRight = !tuple.Item2.Any();
             result.PassConnectorsName += string.Join("、", tuple.Item1.ToArray());
             result.UnPassConnectorsName += string.Join("、", tuple.Item2.ToArray());
@@ -122,12 +122,12 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="result"></param>
         /// <param name="domain"></param>
-        private Tuple<List<string>,List<string>> CheckConType(FamilyInstance fi, List<string> referSystems)
+        private Tuple<List<string>,List<string>> CheckConType(Element element, List<string> referSystems)
         {
             List<string> passList=new List<string>();
             List<string> unpassList=new List<string>();
 
-            var connectors = fi.GetAllConnectors();
+            var connectors = element.GetAllConnectors();
             foreach (Connector connector in connectors)
             {
                 try
@@ -135,7 +135,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     var mepSystem = connector.MEPSystem;
                     if (mepSystem == null) continue;
                     var elementId = mepSystem.GetTypeId();
-                    var type = fi.Document.GetElement(elementId);
+                    var type = element.Document.GetElement(elementId);
                     if (!referSystems.Contains(type.Name))
                     {
                         unpassList.Add(type.Name);
@@ -147,7 +147,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 }
                 catch (Exception e)
                 {
-                   Log4Net.Info($"读取连接件系统错误。Id:{fi.Id},Path:{fi.Document.PathName}");
+                   Log4Net.Info($"读取连接件系统错误。Id:{element.Id},Path:{element.Document.PathName}");
                 }
             }
 

+ 4 - 4
MBI/SAGA.MBI/ToolsData/ModeCheck/EquipmentInSpaceCheck.cs

@@ -52,10 +52,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             foreach (SagaSignCheckResult signResult in RBase.Results)
             {
                 var document = signResult.RDocument;
-                var elements = document.GetFamilyInstances();
+                var elements = document.GetMbiElements();
                 var parts = elements.Where(t => t.IsEquipment()|| t.IsEquipmentPart());
                 var rspaces = document.GetSpaces().Where(t => t.IsValidObject).ToList();
-                foreach (FamilyInstance fi in parts)
+                foreach (Element fi in parts)
                 {
                     var result = GetCheckResult(fi,rspaces);
                     result.RBase = signResult;
@@ -70,10 +70,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private ModeCheckResultBase GetCheckResult(FamilyInstance fi,List<Space> spaces)
+        private ModeCheckResultBase GetCheckResult(Element fi,List<Space> spaces)
         {
             var result = new EquipmentInSpaceCheckResult();
-            result.FamilyName = fi.GetFamily().Name;
+            result.FamilyName = fi.GetFamilyName();
             result.Id = fi.Id.ToString();
             var space = fi.GetReferenceSpace(spaces);
             if (space == null)

+ 4 - 4
MBI/SAGA.MBI/ToolsData/ModeCheck/EquipmentPartRefEqCheck.cs

@@ -51,9 +51,9 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             foreach (SagaSignCheckResult signResult in RBase.Results)
             {
                 var document = signResult.RDocument;
-                var elements = document.GetFamilyInstances();
+                var elements = document.GetMbiElements();
                 var parts = elements.Where(t =>  t.IsEquipmentPart());
-                foreach (FamilyInstance fi in parts)
+                foreach (Element fi in parts)
                 {
                     var result = GetCheckResult(fi);
                     result.RBase = signResult;
@@ -68,10 +68,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
+        private ModeCheckResultBase GetCheckResult(Element fi)
         {
             var result = new EquipmentPartRefEqCheckResult();
-            result.FamilyName = fi.GetFamily().Name;
+            result.FamilyName = fi.GetFamilyName();
             result.Id = fi.Id.ToString();
             var partParent = DalEquipPart.GetPartParentElement(fi);
             if (partParent == null)

+ 2 - 2
MBI/SAGA.MBI/ToolsData/ModeCheck/FamilyNameCheck.cs

@@ -68,7 +68,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                         if (category == null) continue;
                         BuiltInCategory builtInCategory = (BuiltInCategory)category.Id.IntegerValue;
                         var elements = document.GetElements<FamilyInstance>(builtInCategory);
-                        var groupByFamily = elements.GroupBy(t => t.GetFamily()?.Name);
+                        var groupByFamily = elements.GroupBy(t => t.GetFamilyName());
                         foreach (IGrouping<string, FamilyInstance> grouping in groupByFamily)
                         {
                             var subElements = grouping.ToList();
@@ -111,7 +111,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
         {
             var result = new FamilyNameCheckResult();
-            result.FamilyName = fi.GetFamily().Name;
+            result.FamilyName = fi.GetFamilyName();
             result.Id = fi.Id.ToString();
             if (fi.IsEquipment())
             {

+ 5 - 5
MBI/SAGA.MBI/ToolsData/ModeCheck/ParameterIntegrityCheck.cs

@@ -57,13 +57,13 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             foreach (SagaSignCheckResult signResult in RBase.Results)
             {
                 var doc = signResult.RDocument;
-                var instances = doc.GetFamilyInstances();
+                var instances = doc.GetMbiElements();
                 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)
+                var familyGroups = mbiItems.GroupBy(t => t.GetFamilyName());
+                foreach (IGrouping<string, Element> familyGroup in familyGroups)
                 {
                     string familyName = familyGroup.Key;
-                    FamilyInstance fi = familyGroup.FirstOrDefault();
+                    Element fi = familyGroup.FirstOrDefault();
                     var result = GetCheckResult(fi);
                     if (result == null) continue;
                     result.FamilyName = familyName;
@@ -78,7 +78,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         /// </summary>
         /// <param name="fi"></param>
         /// <returns></returns>
-        private ParameterIntegrityCheckResult GetCheckResult(FamilyInstance fi)
+        private ParameterIntegrityCheckResult GetCheckResult(Element fi)
         {
             var result = new ParameterIntegrityCheckResult(){IsRight = true};
             var localNameParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalName);

+ 3 - 3
MBI/SAGA.MBI/ToolsData/UpdateRelationEquipinSpace.cs

@@ -156,9 +156,9 @@ namespace SAGA.MBI.ToolsData
 
         private static string GetMSpace(Document doc, string bimid, List<MISpace> spaces)
         {
-            FamilyInstance fi = doc.GetElement(bimid.GetBIMID()) as FamilyInstance;
-            if (fi == null) return null;
-            var space = fi.GetReferenceSpace();
+            Element element = doc.GetElement(bimid.GetBIMID());
+            if (element == null) return null;
+            var space = element.GetReferenceSpace();
             if (space == null) return null;
             var spaceid = space.GetCloudBIMId();
             var mspace = spaces.FirstOrDefault(t => t.BimID == spaceid);

+ 1 - 1
MBI/SAGA.MBI/WinView/BeModingDutyList/MEquipNoMode.cs

@@ -247,7 +247,7 @@ namespace SAGA.MBI.WinView.BeModingDutyList
             RltEquipinFloor rlt = new RltEquipinFloor(MEquipBase.Id, floorid) { Operator = DocumentChangedOperator.Add };
             rlt.AddorUpdateObject();
             //处理设备所在空间
-            Autodesk.Revit.DB.Mechanical.Space space = (element as FamilyInstance)?.Space;
+            Autodesk.Revit.DB.Mechanical.Space space = element.GetReferenceSpace();
             if (space != null)
             {
                 var spaceM = DalSpace.GetSpaceQueryId(space);

+ 1 - 1
MBI/SAGA.RevitUtils/Extends/FamilyInstanceExtend.cs

@@ -35,7 +35,7 @@ namespace SAGA.RevitUtils.Extends
         /// </summary>
         /// <param name="instance"></param>
         /// <returns></returns>
-        public static bool IsAllColumn(this FamilyInstance instance)
+        public static bool IsAllColumn(this Element instance)
         {
             return instance.IsAcColumn() || instance.IsStColumn();
         }

+ 9 - 0
MBI/SAGA.RevitUtils/Extends/WallExtend.cs

@@ -39,6 +39,15 @@ namespace SAGA.RevitUtils.Extends
         {
             return wall.GetParameterDouble(BuiltInParameter.HOST_AREA_COMPUTED).FromApi(DisplayUnitType.DUT_SQUARE_METERS);
         }
+        /// <summary>
+        /// 是否为幕墙
+        /// </summary>
+        /// <param name="wall"></param>
+        /// <returns></returns>
+        public static bool IsCurtaiWall(this Wall wall)
+        {
+            return wall?.WallType?.Kind == WallKind.Curtain;
+        }
 
         /// <summary>
         /// 墙底部标高Id

File diff suppressed because it is too large
+ 0 - 1361
MBI/SAGA.RevitUtils/Geometry/Geometry2D.cs


+ 0 - 1
MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

@@ -257,7 +257,6 @@
     <Compile Include="ExtensibleStorage\EnumDefination.cs" />
     <Compile Include="Geometry\EdgeInfo.cs" />
     <Compile Include="Geometry\Geometry.cs" />
-    <Compile Include="Geometry\Geometry2D.cs" />
     <Compile Include="Information.cs" />
     <Compile Include="Infrastructure\DoubleCompare.cs" />
     <Compile Include="Infrastructure\XYZByQuadrantCompare.cs" />