瀏覽代碼

xls:统一视图,空间重复处理

xulisong 6 年之前
父節點
當前提交
62fd66e3e2

+ 21 - 1
MBI/SAGA.MBI/Common/PhaseUtil.cs

@@ -7,6 +7,8 @@
 
 using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
+using SAGA.MBI.Tools;
+using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 using System;
 using System.Collections.Generic;
@@ -121,7 +123,10 @@ namespace SAGA.MBI.Common
             {
                 return new List<Space>();
             }
-            return sourceSpaces.Where(s => s.GetCurrentPhaseId() == useId && s.Area > 0.001).ToList();
+
+            return
+                sourceSpaces.Where(s => s.IsSpace())
+                    .ToList(); // sourceSpaces.Where(s => s.GetCurrentPhaseId() == useId && s.Area > 0.001).ToList();
         }
         /// <summary>
         /// 判断是否是阶段1的空间
@@ -134,5 +139,20 @@ namespace SAGA.MBI.Common
             var useId = GetUsePhaseId(doc);
             return space.GetCurrentPhaseId() == useId;
         }
+        /// <summary>
+        /// 空间标高是否是当前使用视图标高
+        /// </summary>
+        /// <param name="space"></param>
+        /// <returns></returns>
+        public static bool IsViewLevel(this Space space)
+        {
+            var doc = space.Document;
+            var useViewId = doc.GetUseView();
+            if (useViewId == null)
+            {
+                return false;
+            }
+            return space.Level?.Id== useViewId.GenLevel?.Id;
+        }
     }
 }

+ 9 - 1
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -100,7 +100,15 @@ namespace SAGA.MBI.Tools
                 //空间比较特殊,周长为零就相当于删除
                 isspace = !ischeckzero || !(space.IsDeleteSpace());
                 //限制所用空间的阶段
-                //isspace = isspace && space.IsPhase1Space();
+                if (isspace)
+                {
+                    //增加过滤效率,如果上一步正确菜继续往下执行。
+                    isspace = isspace && space.IsPhase1Space();
+                }               
+                if (isspace)
+                {
+                    isspace = isspace && space.IsViewLevel();
+                }
             }
 
             return isspace;

+ 1 - 1
MBI/SAGA.MBI/Interaction/MBIModelInfoUpload.cs

@@ -83,7 +83,7 @@ namespace SAGA.MBI.Interaction
             {
                 if(context==null)continue;
                 try
-                {
+                {                 
                     context.OpenDocument();
                     Document doc = context.RevitDoc;
                     MbiElementManager.ExecuteExport(doc);

+ 1 - 1
MBI/SAGA.MBI/RevitExport/ExportData.cs

@@ -62,7 +62,7 @@ namespace SAGA.MBI.RevitExport
             // data.Spaces.AddRange(collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Space }));
             //增加空间排序功能
             var originSpaces = collector.Clone().GetUseSpaces();
-            var useSpaces = SpaceSortUtils.Sort(originSpaces);
+            var useSpaces =  SpaceSortUtils.Sort(originSpaces);
             data.Spaces.AddRange(useSpaces.Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Space }));
             var familyInstances = collector.Clone().FilterElements<FamilyInstance>();
             foreach (FamilyInstance familyInstance in familyInstances)

+ 18 - 4
MBI/SAGA.MBI/RevitExport/SpaceSortUtils.cs

@@ -38,6 +38,11 @@ namespace SAGA.MBI.RevitExport
 
         private static int CalcLevel(SpaceDecorator input, List<SpaceDecorator> decorators)
         {
+            /*
+             * 增加忽略上级选型,避免递归
+             *
+             * 由于包含的这种关系
+             */
             if (input.IsHandled)
             {
                 return input.Level;
@@ -94,12 +99,21 @@ namespace SAGA.MBI.RevitExport
             if (PolygonUtil.IsIntersection(basePolygon, refPolygon))
             {
                 var pointList = basePolygon.ToList();
-                if (refPolygon.All(p => p.PointInPolygonByRay(pointList) > -1))
+                var existIn = false;
+                foreach (var point in refPolygon)
                 {
-                    //所有点都在外轮廓线内
-                    return true;
+                    var inFlag = point.PointInPolygonByRay(pointList);
+                    if (inFlag == -1)
+                    {
+                        return false;
+                    }
+                    else if (inFlag == 1)
+                    {
+                        existIn = true;
+                    }
                 }
-                
+
+                flag = existIn;//完全相等不视为包含。
             }
             return flag;
         }

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

@@ -551,7 +551,7 @@ namespace SAGA.MBI
                     }
                 case System.Windows.Forms.DialogResult.No:
                     {
-                        MbiElementManager.ExecuteExport(ExternalDataWrapper.Current.Doc);
+                        //MbiElementManager.ExecuteExport(ExternalDataWrapper.Current.Doc);
                         UpdateLevleName(ExternalDataWrapper.Current.Doc);
                         break;
                     }