Browse Source

mxg:修改导出ElementType异常问题

mengxiangge 5 năm trước cách đây
mục cha
commit
c03be448e5

+ 4 - 0
JBIM/JBIM/Component/Grid.cs

@@ -8,12 +8,16 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using JBIM.Common;
+using JBIM.Component;
+using JBIM.Definition;
 
 namespace JBIM.Component
 {
     /// <summary>
     /// Grid
     /// </summary>
+    [TypeDefiniton(TypeDefinition.Grid)]
     public class Grid: VisibleComponentObject
     {
     }

+ 3 - 0
JBIM/JBIM/Component/Level.cs

@@ -3,17 +3,20 @@
  * 创 建 者:Garrett
  * 创建日期:2019/6/26 15:01:44
  * ==============================================================================*/
+using JBIM.Definition;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using JBIM.Common;
 
 namespace JBIM.Component
 {
     /// <summary>
     /// Level
     /// </summary>
+    [TypeDefiniton(TypeDefinition.Level)]
     public class Level:VisibleComponentObject
     {
         //标高的高度

+ 3 - 0
JBIM/JBIM/Component/Unit.cs

@@ -3,17 +3,20 @@
  * 创 建 者:Garrett
  * 创建日期:2019/6/26 15:02:34
  * ==============================================================================*/
+using JBIM.Definition;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using JBIM.Common;
 
 namespace JBIM.Component
 {
     /// <summary>
     /// Unit
     /// </summary>
+    [TypeDefiniton(TypeDefinition.Unit)]
     public class Unit:ComponentObject
     {
         //单位的值

+ 2 - 1
JBIM/RevitToJBim/ComponentParse/ParseUnit.cs

@@ -11,6 +11,7 @@ using System.Threading.Tasks;
 using JBIM;
 using RevitExport.Export;
 using Autodesk.Revit.DB;
+using RevitToJBim.Common;
 using JUnit=JBIM.Component.Unit;
 
 namespace RevitToJBim.ComponentParse
@@ -23,7 +24,7 @@ namespace RevitToJBim.ComponentParse
     {
         public override List<string> FastIndex()
         {
-            return new List<string>() { typeof(FormatOptions).FullName };
+            return new List<string>() { CategoryGenerator.BuildingCategory(Common.FamilyType.Other) };
         }
         public override bool Match(ElementWrapper wrapper)
         {

+ 2 - 1
JBIM/RevitToJBim/ExportDataBuilder.cs

@@ -16,6 +16,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using RevitToJBim.Extension;
 
 namespace RevitToJBim
 {
@@ -41,7 +42,7 @@ namespace RevitToJBim
             FilteredElementCollector collector = new FilteredElementCollector(doc);
             wrappers.AddRange(collector.Clone().FilterElements<Wall>().Select(e => new ElementWrapper(e)));
             wrappers.AddRange(collector.Clone().FilterElements<CurveElement>(BuiltInCategory.OST_MEPSpaceSeparationLines).Select(e => new ElementWrapper(e)));
-            var sourceSpaces = collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().ToList();
+            var sourceSpaces = collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().Where(t=>t.IsSpace()).ToList();
             //附加逻辑判断
             //  var originSpaces = collector.Clone().GetUseSpaces();
 

+ 9 - 1
JBIM/RevitToJBim/Extension/ElementExtension.cs

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

+ 89 - 0
JBIM/RevitToJBim/Extension/SpaceExtension.cs

@@ -0,0 +1,89 @@
+/* ==============================================================================
+ * 功能描述:SpaceExtension  
+ * 创 建 者:Garrett
+ * 创建日期:2019/6/26 17:40:25
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+using SAGA.RevitUtils;
+using SAGA.RevitUtils.Extends;
+
+namespace RevitToJBim.Extension
+{
+    /// <summary>
+    /// SpaceExtension
+    /// </summary>
+    public static class SpaceExtension
+    {
+        public readonly static string UseablePhaseName = "阶段1";
+
+        /// <summary>
+        /// 获取系统使用的阶段Id
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <returns></returns>
+        public static ElementId GetUsePhaseId(this Document doc)
+        {
+            var phase = GetUsePhase(doc);
+            if (phase == null)
+            {
+                return ElementId.InvalidElementId;
+            }
+            return phase.Id;
+        }
+        /// <summary>
+        /// 获取系统使用的阶段
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <returns></returns>
+        public static Phase GetUsePhase(this Document doc)
+        {
+            var elements = doc.GetElements<Phase>(BuiltInCategory.OST_Phases);
+            foreach (var element in elements)
+            {
+                var tempName = element.Name.Replace(" ", "").Trim();
+                if (UseablePhaseName == tempName)
+                {
+                    return element;
+                }
+            }
+            return null;
+        }
+
+        public static ElementId GetCurrentPhaseId(this Space space)
+        {
+            return space.GetParameterElementId(BuiltInParameter.ROOM_PHASE_ID) ?? ElementId.InvalidElementId;
+        }
+        /// <summary>
+        /// 判断是否是阶段1的空间
+        /// </summary>
+        /// <param name="space"></param>
+        /// <returns></returns>
+        public static bool IsPhase1Space(this Space space)
+        {
+            var doc = space.Document;
+            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;
+        }
+    }
+}

+ 1 - 0
JBIM/RevitToJBim/RevitToJBim.csproj

@@ -69,6 +69,7 @@
     <Compile Include="ComponentParse\ParseGrid.cs" />
     <Compile Include="ComponentParse\ParseLevel.cs" />
     <Compile Include="ComponentParse\ParseUnit.cs" />
+    <Compile Include="Extension\SpaceExtension.cs" />
     <Compile Include="JsonConverter\ParameterConverter.cs" />
     <Compile Include="MBI\MBIBuiltInParameterName.cs" />
     <Compile Include="MBI\MBIRegexPattern.cs" />