xulisong 5 éve
szülő
commit
394ec8e37e
43 módosított fájl, 1647 hozzáadás és 0 törlés
  1. 3 0
      .gitignore
  2. BIN
      JBIM/Dlls/RevitAPI.dll
  3. BIN
      JBIM/Dlls/RevitAPIUI.dll
  4. BIN
      JBIM/Dlls/SAGA.RevitUtils.dll
  5. 37 0
      JBIM/JBIM.sln
  6. 70 0
      JBIM/JBIM/BimDocument.cs
  7. 53 0
      JBIM/JBIM/BimId.cs
  8. 46 0
      JBIM/JBIM/BimObject.cs
  9. 33 0
      JBIM/JBIM/Common/TypeDefinitonAttribute.cs
  10. 23 0
      JBIM/JBIM/Common/TypeDefinitonUtil.cs
  11. 29 0
      JBIM/JBIM/Component/BoundarySegment.cs
  12. 34 0
      JBIM/JBIM/Component/ComponentObject.cs
  13. 56 0
      JBIM/JBIM/Component/Connector.cs
  14. 40 0
      JBIM/JBIM/Component/Duct.cs
  15. 24 0
      JBIM/JBIM/Component/MepSystem.cs
  16. 21 0
      JBIM/JBIM/Component/MepSystemType.cs
  17. 25 0
      JBIM/JBIM/Component/Pipe.cs
  18. 26 0
      JBIM/JBIM/Component/Space.cs
  19. 35 0
      JBIM/JBIM/Component/VisibleComponentObject.cs
  20. 35 0
      JBIM/JBIM/Definition/ConnectorShape.cs
  21. 44 0
      JBIM/JBIM/Definition/TypeDefinition.cs
  22. 32 0
      JBIM/JBIM/Definition/XYZ.cs
  23. 19 0
      JBIM/JBIM/Geometry/GeometryObject.cs
  24. 96 0
      JBIM/JBIM/JBIM.csproj
  25. 55 0
      JBIM/JBIM/Properties/AssemblyInfo.cs
  26. 71 0
      JBIM/JBIM/Properties/Resources.Designer.cs
  27. 117 0
      JBIM/JBIM/Properties/Resources.resx
  28. 30 0
      JBIM/JBIM/Properties/Settings.Designer.cs
  29. 7 0
      JBIM/JBIM/Properties/Settings.settings
  30. 22 0
      JBIM/RevitExport/Export/ElementWrapper.cs
  31. 66 0
      JBIM/RevitExport/Export/ExportInstance.cs
  32. 42 0
      JBIM/RevitExport/Parse/IParseElement.cs
  33. 26 0
      JBIM/RevitExport/Parse/ParseContext.cs
  34. 73 0
      JBIM/RevitExport/Parse/ParseInstance.cs
  35. 36 0
      JBIM/RevitExport/Properties/AssemblyInfo.cs
  36. 61 0
      JBIM/RevitExport/RevitExport.csproj
  37. 24 0
      JBIM/RevitToJBim/Common/RevitIdGenerator.cs
  38. 23 0
      JBIM/RevitToJBim/ComponentParse/ParseBase.cs
  39. 30 0
      JBIM/RevitToJBim/ComponentParse/ParseCore.cs
  40. 29 0
      JBIM/RevitToJBim/ComponentParse/ParsePipe.cs
  41. 47 0
      JBIM/RevitToJBim/JBimParseContext.cs
  42. 36 0
      JBIM/RevitToJBim/Properties/AssemblyInfo.cs
  43. 71 0
      JBIM/RevitToJBim/RevitToJBim.csproj

+ 3 - 0
.gitignore

@@ -3,3 +3,6 @@
 ################################################################################
 
 /JBIM/.vs/JBIM/v15
+/JBIM/RevitExport/obj/Debug
+/JBIM/JBIM/obj/Debug
+/JBIM/RevitToJBim/obj/Debug

BIN
JBIM/Dlls/RevitAPI.dll


BIN
JBIM/Dlls/RevitAPIUI.dll


BIN
JBIM/Dlls/SAGA.RevitUtils.dll


+ 37 - 0
JBIM/JBIM.sln

@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28010.2050
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JBIM", "JBIM\JBIM.csproj", "{A6A90BFE-126D-4499-860A-F0E2C40EBB23}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitExport", "RevitExport\RevitExport.csproj", "{825B43F4-1F7B-44AC-9BD4-501DE9422D32}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitToJBim", "RevitToJBim\RevitToJBim.csproj", "{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{A6A90BFE-126D-4499-860A-F0E2C40EBB23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A6A90BFE-126D-4499-860A-F0E2C40EBB23}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A6A90BFE-126D-4499-860A-F0E2C40EBB23}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A6A90BFE-126D-4499-860A-F0E2C40EBB23}.Release|Any CPU.Build.0 = Release|Any CPU
+		{825B43F4-1F7B-44AC-9BD4-501DE9422D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{825B43F4-1F7B-44AC-9BD4-501DE9422D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{825B43F4-1F7B-44AC-9BD4-501DE9422D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{825B43F4-1F7B-44AC-9BD4-501DE9422D32}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {6ADA978E-6CF2-4C12-AEAE-D090120BEBE2}
+	EndGlobalSection
+EndGlobal

+ 70 - 0
JBIM/JBIM/BimDocument.cs

@@ -0,0 +1,70 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:BimDocument
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 11:01:06
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM
+{
+    /// <summary>
+    /// Bim文件类信息
+    /// </summary>
+    public class BimDocument
+    {
+        public BimDocument()
+        {
+            BimObjects = new ReadOnlyCollection<BimObject>(m_InnerObjects = new List<BimObject>());
+        }
+
+        private List<BimObject> m_InnerObjects;
+        private Dictionary<BimId, BimObject> m_IndexObjects = new Dictionary<BimId, BimObject>();
+        /// <summary>
+        /// 关联所有对象
+        /// </summary>
+        public ReadOnlyCollection<BimObject> BimObjects { get; private set; }
+
+        /// <summary>
+        /// 当前索引信息
+        /// </summary>
+        private long CurrentIndex { get; set; } = 10000;
+        internal BimId GenerateId()
+        {
+            return new BimId((++CurrentIndex).ToString());
+        }
+
+        public BimObject NewObject(BimObject originObject)
+        {
+            if (originObject.Id == null)
+            {
+                originObject.Id = GenerateId();
+            }
+
+            AddObject(originObject);
+            return originObject;
+        }
+
+        private void AddObject(BimObject originObject)
+        {
+            this.m_InnerObjects.Add(originObject);
+            m_IndexObjects[originObject.Id] = originObject;
+        }
+
+        public BimObject GetBimObject(BimId id)
+        {
+            //查询可优化,简单的二分查找
+            if (m_IndexObjects.TryGetValue(id, out BimObject result))
+            {
+                return result;
+            }
+            return null;
+        }
+    }
+}

+ 53 - 0
JBIM/JBIM/BimId.cs

@@ -0,0 +1,53 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:BimId
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 9:57:38
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM
+{
+    /*
+     * 定义BimId类,初始化相关ID类型的引用
+     * 引入该类,是为了方便在Id这一类型上的扩展,毕竟它和普通的基本类型有所不同
+     */
+    /// <summary>
+    /// bimId类
+    /// </summary>
+    public class BimId
+    {
+        public BimId(string id)
+        {
+            this.Id = id;
+        }
+        /// <summary>
+        /// Id值
+        /// </summary>
+        public string Id { get; private set; }
+
+        public override bool Equals(object obj)
+        {
+            if (obj is BimId inputId)
+            {
+                return Id == inputId.Id;
+
+            }
+            return false;
+        }
+        public override int GetHashCode()
+        {
+            if (string.IsNullOrWhiteSpace(Id))
+            {
+                return 0;
+            }
+
+            return Id.GetHashCode();
+        }
+    }
+}

+ 46 - 0
JBIM/JBIM/BimObject.cs

@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:BimObject
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:36:34
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM
+{
+    [TypeDefiniton(TypeDefinition.BimObject)]
+    public class BimObject
+    {
+        public BimObject()
+        {
+            ElementType = GetElementType();
+        }
+       public BimId Id { get;internal set; }
+       public string ElementType { get;protected set; }
+        /// <summary>
+        /// 获取类型Type
+        /// </summary>
+        /// <returns></returns>
+        protected string GetElementType()
+        {
+           var attributes= this.GetType().GetCustomAttributes(typeof(TypeDefinitonAttribute), true);
+            string result = null;
+            if (attributes.Any())
+            {
+                result=(attributes[0] as TypeDefinitonAttribute)?.GetTypeDefiniton();
+            }
+
+            if (string.IsNullOrEmpty(result))
+            {
+                result= TypeDefinitonUtil.GetTypeDefiniton(TypeDefinition.BimObject);
+            }
+            return result;
+        }
+    }
+}

+ 33 - 0
JBIM/JBIM/Common/TypeDefinitonAttribute.cs

@@ -0,0 +1,33 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:TypeDefinitonAttribute
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:26:04
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM.Common
+{
+    [AttributeUsage(AttributeTargets.Class)]
+    public class TypeDefinitonAttribute:Attribute
+    {
+        /*
+         * 由于可能扩展相关TypeDefiniton的生成方式,所以以方法形式返回需要值
+         */
+        private TypeDefinition m_TypeDefintion;
+        public TypeDefinitonAttribute(TypeDefinition typeDefinition)
+        {
+            m_TypeDefintion = typeDefinition;
+        }
+
+        public virtual string GetTypeDefiniton()
+        {
+            return TypeDefinitonUtil.GetTypeDefiniton(m_TypeDefintion);
+        }
+    }
+}

+ 23 - 0
JBIM/JBIM/Common/TypeDefinitonUtil.cs

@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:TypeDefinitonUtil
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 11:31:46
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM.Common
+{
+    public static class TypeDefinitonUtil
+    {
+        public static string GetTypeDefiniton(TypeDefinition typeDefinition)
+        {
+            return typeDefinition.ToString();
+        }
+    }
+}

+ 29 - 0
JBIM/JBIM/Component/BoundarySegment.cs

@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:BoundarySegment
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:51:21
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    [TypeDefiniton(TypeDefinition.BoundarySegment)]
+    public class BoundarySegment:BimObject
+    {
+        public BoundarySegment()
+        {
+            Curve = new List<XYZ>();
+        }
+        /// <summary>
+        /// 关联线
+        /// </summary>
+        public List<XYZ> Curve { get; private set; }
+    }
+}

+ 34 - 0
JBIM/JBIM/Component/ComponentObject.cs

@@ -0,0 +1,34 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ComponentObject
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:41:01
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// 构件对象
+    /// </summary>
+    public class ComponentObject:BimObject
+    {
+        /// <summary>
+        /// 数据来源Id
+        /// </summary>
+        public string SourceId { get; set; }
+        /// <summary>
+        /// 构件名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 构件关联类型Id
+        /// </summary>
+        public BimId TypeId { get; set; }
+    }
+}

+ 56 - 0
JBIM/JBIM/Component/Connector.cs

@@ -0,0 +1,56 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:Connector
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:04:03
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// Connector信息
+    /// </summary>
+    [TypeDefiniton(TypeDefinition.Connector)]
+    public class Connector:ComponentObject
+    {
+        public Connector()
+        {
+            ConnectedIds = new List<BimId>();
+        }
+        /// <summary>
+        /// Connector所属专业域
+        /// </summary>
+        public string Domain { get; set; }
+        /// <summary>
+        /// 定位点
+        /// </summary>
+        public XYZ Origin { get; set; }
+        /// <summary>
+        /// 信息描述
+        /// </summary>
+        public string Description { get; set; }
+        /// <summary>
+        /// 是否连接
+        /// </summary>
+        public string IsConnected { get; set; }
+        /// <summary>
+        /// Connector所属构件
+        /// </summary>
+        public BimId Owner { get; set; }
+        /// <summary>
+        /// Connector连接的connectorId
+        /// </summary>
+        public List<BimId> ConnectedIds { get;private set; }
+        /// <summary>
+        /// connector关联的系统实例
+        /// </summary>
+        public BimId MepSystem { get; set; }
+    }
+}

+ 40 - 0
JBIM/JBIM/Component/Duct.cs

@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:Duct
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:10:06
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// 风管类型
+    /// </summary>
+    [TypeDefiniton(TypeDefinition.Duct)]
+    public class Duct:VisibleComponentObject
+    {
+        /// <summary>
+        /// 风管形状
+        /// </summary>
+        public DuctShape Shape { get; set; }
+        /// <summary>
+        /// 直径
+        /// </summary>
+        public double Diameter { get; set; }
+        /// <summary>
+        /// 宽度
+        /// </summary>
+        public double Width { get; set; }
+        /// <summary>
+        /// 高度
+        /// </summary>
+        public double Height { get; set; }
+    }
+}

+ 24 - 0
JBIM/JBIM/Component/MepSystem.cs

@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MepSystem
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:00:35
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// mep系统相关
+    /// </summary>
+    [TypeDefiniton(TypeDefinition.MepSystem)]
+    public class MepSystem: ComponentObject
+    {
+    }
+}

+ 21 - 0
JBIM/JBIM/Component/MepSystemType.cs

@@ -0,0 +1,21 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MepSystemType
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:03:47
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    [TypeDefiniton(TypeDefinition.MepSystemType)]
+    public class MepSystemType : ComponentObject
+    {
+    }
+}

+ 25 - 0
JBIM/JBIM/Component/Pipe.cs

@@ -0,0 +1,25 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:Pipe
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 11:09:56
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    [TypeDefiniton(TypeDefinition.Pipe)]
+    public class Pipe:VisibleComponentObject
+    {
+        /// <summary>
+        /// 管道直径
+        /// </summary>
+        public double Diameter { get; set; }
+    }
+}

+ 26 - 0
JBIM/JBIM/Component/Space.cs

@@ -0,0 +1,26 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:Space
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 14:11:03
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+
+namespace JBIM.Component
+{
+    [TypeDefiniton(TypeDefinition.Space)]
+    public class Space:VisibleComponentObject
+    {
+        public Space()
+        {
+            BoundarySegments = new List<BimId>();
+        }
+        public List<BimId> BoundarySegments { get; private set; }
+    }
+}

+ 35 - 0
JBIM/JBIM/Component/VisibleComponentObject.cs

@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:VisibleComponentObject
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:44:44
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// 可见构件
+    /// </summary>
+    public class VisibleComponentObject:ComponentObject
+    {
+        public VisibleComponentObject()
+        {
+            Location = new List<XYZ>();
+            OutLine = new List<Polygon>();
+        }
+        /// <summary>
+        /// 定位信息
+        /// </summary>
+        public List<XYZ> Location { get; private set; }
+        /// <summary>
+        /// 轮廓信息
+        /// </summary>
+        public List<Polygon> OutLine { get; private set; }
+    }
+}

+ 35 - 0
JBIM/JBIM/Definition/ConnectorShape.cs

@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ConnectorShape
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:24:24
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM
+{
+    /// <summary>
+    /// 连接点形状
+    /// </summary>
+    public enum ConnectorShape
+    {
+        Undefine = 0,
+        Circle=1,
+        Rectangle=2,
+        Ellipse=3
+    }
+    /// <summary>
+    /// 风管形状
+    /// </summary>
+    public enum DuctShape
+    {
+        Circle=1,
+        Rectangle=2,
+        Ellipse=3
+    }
+}

+ 44 - 0
JBIM/JBIM/Definition/TypeDefinition.cs

@@ -0,0 +1,44 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:TypeDefinition
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:12:56
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM
+{
+    /*
+      类型Id范围:[-10000,-19999)
+      {Id:"xxxxxx",ElementType:"Connector"}
+      //或者硬编码成枚举,或者使用配置文件存储
+     */
+    /// <summary>
+    /// 类型定义
+    /// </summary>
+    public enum TypeDefinition
+    {
+        [Description("Connector")]
+        BimObject = -10000,
+        [Description("Connector")]
+        Connector= BimObject-1,
+        [Description("Duct")]
+        Duct = BimObject - 2,
+        [Description("Pipe")]
+        Pipe = BimObject - 3,
+        [Description("Space")]
+        Space = BimObject - 4,
+        [Description("MepSystem")]
+        MepSystem = BimObject - 5,
+        [Description("MepSystemType")]
+        MepSystemType = BimObject - 6,
+        [Description("BoundarySegment")]
+        BoundarySegment = BimObject - 7,
+    }
+}

+ 32 - 0
JBIM/JBIM/Definition/XYZ.cs

@@ -0,0 +1,32 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:XYZ
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:46:22
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM
+{
+    public class XYZ
+    {
+        public double X { get; set; }
+        public double Y { get; set; }
+        public double Z { get; set; }
+    }
+    public class XY
+    {
+        public double X { get; set; }
+        public double Y { get; set; }
+    }
+
+    public class Polygon : List<XYZ>
+    {
+
+    }
+}

+ 19 - 0
JBIM/JBIM/Geometry/GeometryObject.cs

@@ -0,0 +1,19 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:GeometryObject
+ * 作者:xulisong
+ * 创建时间: 2019/6/12 10:37:00
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JBIM.Geometry
+{
+    public class GeometryObject: BimObject
+    {
+    }
+}

+ 96 - 0
JBIM/JBIM/JBIM.csproj

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{A6A90BFE-126D-4499-860A-F0E2C40EBB23}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>JBIM</RootNamespace>
+    <AssemblyName>JBIM</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BimDocument.cs" />
+    <Compile Include="BimId.cs" />
+    <Compile Include="BimObject.cs" />
+    <Compile Include="Common\TypeDefinitonAttribute.cs" />
+    <Compile Include="Common\TypeDefinitonUtil.cs" />
+    <Compile Include="Component\BoundarySegment.cs" />
+    <Compile Include="Component\ComponentObject.cs" />
+    <Compile Include="Component\Connector.cs" />
+    <Compile Include="Component\Duct.cs" />
+    <Compile Include="Component\MepSystem.cs" />
+    <Compile Include="Component\MepSystemType.cs" />
+    <Compile Include="Component\Pipe.cs" />
+    <Compile Include="Component\Space.cs" />
+    <Compile Include="Component\VisibleComponentObject.cs" />
+    <Compile Include="Definition\ConnectorShape.cs" />
+    <Compile Include="Definition\XYZ.cs" />
+    <Compile Include="Geometry\GeometryObject.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <Compile Include="Definition\TypeDefinition.cs" />
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 55 - 0
JBIM/JBIM/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("JBIM")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("JBIM")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 <UICulture> 设置为 en-US。  然后取消
+//对以下 NeutralResourceLanguage 特性的注释。  更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+                                     //(未在页面中找到资源时使用,
+                                     //或应用程序资源字典中找到时使用)
+    ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+                                              //(未在页面中找到资源时使用,
+                                              //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
JBIM/JBIM/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace JBIM.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JBIM.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
JBIM/JBIM/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
JBIM/JBIM/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace JBIM.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
JBIM/JBIM/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 22 - 0
JBIM/RevitExport/Export/ElementWrapper.cs

@@ -0,0 +1,22 @@
+using Autodesk.Revit.DB;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitExport
+{
+    /// <summary>
+    /// 元素包装
+    /// </summary>
+    public class ElementWrapper
+    {
+        public ElementWrapper(Element element)
+        {
+            RefElement = element;
+        }
+
+        public Element RefElement { get; private set; }
+    }
+}

+ 66 - 0
JBIM/RevitExport/Export/ExportInstance.cs

@@ -0,0 +1,66 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ExportInstance
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 14:46:48
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitExport
+{
+    /*
+     * 使用event形式,将Export和Parse关联断开
+     */
+    /// <summary>
+    /// 导出实例
+    /// </summary>
+    public class ExportInstance
+    {
+        public ExportInstance(List<ElementWrapper> elements)
+        {
+            ExportElements = elements ?? new List<ElementWrapper>();
+        }
+        /// <summary>
+        /// 待导出元素
+        /// </summary>
+        private List<ElementWrapper> ExportElements { get; set; }
+
+        #region 导出逻辑相关
+        public bool Export()
+        {
+            if (ExportElements == null)
+                return false;
+            for (int i = 0; i < ExportElements.Count; i++)
+            {
+
+                if (IsCancel)
+                    return false;
+                ElementWrapper revitElementWrapper = ExportElements[i];
+                ParseElement?.Invoke(this, new ExportArgs(revitElementWrapper));
+                ProcessChanged?.Invoke(i + 1);
+            }
+            return true;
+        }
+        /// <summary>
+        /// 是否取消
+        /// </summary>
+        public bool IsCancel { get; set; }
+        public event EventHandler<ExportArgs> ParseElement;
+        public event Action<int> ProcessChanged;
+        #endregion
+    }
+
+    public class ExportArgs : EventArgs
+    {
+        public ExportArgs(ElementWrapper elementWrapper)
+        {
+            ElementWrapper = elementWrapper;
+        }
+        public ElementWrapper ElementWrapper { get; private set; }
+    }
+}

+ 42 - 0
JBIM/RevitExport/Parse/IParseElement.cs

@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IParseElement
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 15:06:05
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitExport
+{
+    /// <summary>
+    /// 解析元素类
+    /// </summary>
+    public interface IParseElement
+    {
+        bool Match(ElementWrapper wrapper);
+        /// <summary>
+        /// 解析指定元素
+        /// </summary>
+        /// <param name="wrapper"></param>
+        /// <param name="context"></param>
+        void Parse(ElementWrapper wrapper, ParseContext context);
+    }
+    /// <summary>
+    /// 解析元素类
+    /// </summary>
+    public interface IParseElement<C> where C: ParseContext
+    {
+        bool Match(ElementWrapper wrapper);
+        /// <summary>
+        /// 解析指定元素
+        /// </summary>
+        /// <param name="wrapper"></param>
+        /// <param name="context"></param>
+        void Parse(ElementWrapper wrapper, C context);
+    }
+}

+ 26 - 0
JBIM/RevitExport/Parse/ParseContext.cs

@@ -0,0 +1,26 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ParseContext
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 15:07:22
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitExport
+{
+    /// <summary>
+    /// 解析上下文信息
+    /// </summary>
+    public class ParseContext
+    {
+        /// <summary>
+        /// 关联导出实例
+        /// </summary>
+        public ExportInstance Export { get; internal set; }
+    }
+}

+ 73 - 0
JBIM/RevitExport/Parse/ParseInstance.cs

@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ParseInstance
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 15:04:06
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitExport
+{
+    /*
+     * 最好由导出类控制,导出的开始和结束。这样有一个好处是可以挂接多个解析类。
+     */
+    /// <summary>
+    /// 解析实例
+    /// </summary>
+    public class ParseInstance<C> where C:ParseContext
+    {
+        public ParseInstance(C context,List<IParseElement<C>> parsers)
+        {
+            Context = context;
+            Parsers = parsers;
+        }
+        protected List<IParseElement<C>> Parsers { get; set; }
+        
+        protected virtual IParseElement<C> GetMatchParser(ElementWrapper wrapper)
+        {
+            var currentParse = Parsers.FirstOrDefault(p => p.Match(wrapper));
+            return currentParse;
+        }
+        #region 解析元素相关
+        public virtual void ParseElement(object sender, ExportArgs e)
+        {
+            if (!Parsers.Any())
+                return;
+            ElementWrapper element = e.ElementWrapper;
+            var currentParse = GetMatchParser(element);
+            if (currentParse != null)
+            {
+                currentParse.Parse(element, Context);
+            }
+        }
+
+        /// <summary>
+        /// 当前解析上下文
+        /// </summary>
+        public C Context { get;protected set; }
+
+        /// <summary>
+        /// 解析数据
+        /// </summary>
+        /// <param name="export"></param>
+        /// <returns></returns>
+        public virtual bool Parse(ExportInstance export)
+        {
+            BindingExport(this,export);
+            Context.Export = export;
+            return export.Export();
+        }
+
+        public static void BindingExport(ParseInstance<C> instance, ExportInstance export)
+        {
+            export.ParseElement -= instance.ParseElement;
+            export.ParseElement += instance.ParseElement;
+        }
+        #endregion
+    }
+}

+ 36 - 0
JBIM/RevitExport/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("RevitExport")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RevitExport")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("825b43f4-1f7b-44ac-9bd4-501de9422d32")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 61 - 0
JBIM/RevitExport/RevitExport.csproj

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{825B43F4-1F7B-44AC-9BD4-501DE9422D32}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>RevitExport</RootNamespace>
+    <AssemblyName>RevitExport</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="RevitAPI">
+      <HintPath>..\Dlls\RevitAPI.dll</HintPath>
+    </Reference>
+    <Reference Include="RevitAPIUI">
+      <HintPath>..\Dlls\RevitAPIUI.dll</HintPath>
+    </Reference>
+    <Reference Include="SAGA.RevitUtils">
+      <HintPath>..\Dlls\SAGA.RevitUtils.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Export\ElementWrapper.cs" />
+    <Compile Include="Export\ExportInstance.cs" />
+    <Compile Include="Parse\IParseElement.cs" />
+    <Compile Include="Parse\ParseContext.cs" />
+    <Compile Include="Parse\ParseInstance.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 24 - 0
JBIM/RevitToJBim/Common/RevitIdGenerator.cs

@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:RevitIdGenerator
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 17:06:08
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RevitToJBim.Common
+{
+    public class RevitIdGenerator
+    {
+        public static string GetConnectorId(Connector connector)
+        {
+            return $"{connector.Owner.Id}_C_{connector.Id}";
+        }
+    }
+}

+ 23 - 0
JBIM/RevitToJBim/ComponentParse/ParseBase.cs

@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ParseBase
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 16:55:35
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RevitExport;
+
+namespace RevitToJBim.ComponentParse
+{
+    public abstract class ParseBase : IParseElement<JBimParseContext>
+    {
+        public abstract bool Match(ElementWrapper wrapper);
+        public abstract void Parse(ElementWrapper wrapper, JBimParseContext context);
+
+    }
+}

+ 30 - 0
JBIM/RevitToJBim/ComponentParse/ParseCore.cs

@@ -0,0 +1,30 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ParseCore
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 18:03:03
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM;
+using JBIM.Component;
+
+namespace RevitToJBim.ComponentParse
+{
+    public class ParseCore
+    {
+        public static BimObject GetObject(object obj)
+        {
+            return null;
+        }
+
+        public static Connector CreateConnector(Autodesk.Revit.DB.Connector connector)
+        {
+            return new Connector();
+        }
+    }
+}

+ 29 - 0
JBIM/RevitToJBim/ComponentParse/ParsePipe.cs

@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ParsePipe
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 16:54:19
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RevitExport;
+
+namespace RevitToJBim.ComponentParse
+{
+    public class ParsePipe : ParseBase
+    {
+        public override bool Match(ElementWrapper wrapper)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override void Parse(ElementWrapper wrapper, JBimParseContext context)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 47 - 0
JBIM/RevitToJBim/JBimParseContext.cs

@@ -0,0 +1,47 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:JBimParseContext
+ * 作者:xulisong
+ * 创建时间: 2019/6/13 16:50:43
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM;
+using RevitExport;
+
+namespace RevitToJBim
+{
+    /// <summary>
+    /// JBimParseContext解析上下文
+    /// </summary>
+    public class JBimParseContext: ParseContext
+    {
+        public JBimParseContext()
+        {
+            Document = new BimDocument();
+        }
+        public BimDocument Document { get;private set; }
+
+        #region 数据缓存相关
+
+        private Dictionary<string, BimId> m_RevitIdMap = new Dictionary<string, BimId>();
+        public BimId GetBimId(string revitSourceId)
+        {
+            if (string.IsNullOrWhiteSpace(revitSourceId))
+            {
+                return null;
+            }
+            m_RevitIdMap.TryGetValue(revitSourceId, out BimId result);
+            return result;
+        } 
+        public BimId AddBimObject(BimObject obj)
+        {
+          return  this.Document.NewObject(obj)?.Id;
+        }
+        #endregion
+    }
+}

+ 36 - 0
JBIM/RevitToJBim/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("RevitToJBim")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RevitToJBim")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("f83397d2-c35a-4f5c-8daf-e9de1e2d2ad5")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
JBIM/RevitToJBim/RevitToJBim.csproj

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>RevitToJBim</RootNamespace>
+    <AssemblyName>RevitToJBim</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="RevitAPI">
+      <HintPath>..\Dlls\RevitAPI.dll</HintPath>
+    </Reference>
+    <Reference Include="RevitAPIUI">
+      <HintPath>..\Dlls\RevitAPIUI.dll</HintPath>
+    </Reference>
+    <Reference Include="SAGA.RevitUtils">
+      <HintPath>..\Dlls\SAGA.RevitUtils.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Common\RevitIdGenerator.cs" />
+    <Compile Include="ComponentParse\ParseBase.cs" />
+    <Compile Include="ComponentParse\ParseCore.cs" />
+    <Compile Include="ComponentParse\ParsePipe.cs" />
+    <Compile Include="JBimParseContext.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\JBIM\JBIM.csproj">
+      <Project>{a6a90bfe-126d-4499-860a-f0e2c40ebb23}</Project>
+      <Name>JBIM</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\RevitExport\RevitExport.csproj">
+      <Project>{825b43f4-1f7b-44ac-9bd4-501de9422d32}</Project>
+      <Name>RevitExport</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>