Browse Source

合并衝突

garrett 4 years ago
parent
commit
82079c7f11

+ 7 - 2
Executer/DataCheck/DataCheck.Mode/PipeCheck.cs

@@ -46,7 +46,10 @@ namespace ServiceRevitLib.DataCheck.Mode
                         continue;
                     }
                     var item = new PipeCheckResult();
-                    item.SystemName = element.GetSystemTypeName();
+                    // 如果为软管,则不导出。软管的系统名称为空
+                    var tempSystem = element.GetSystemTypeName();
+                    if (tempSystem.IsNullOrEmpty()) continue;
+                    item.SystemName = tempSystem;
                     item.Id = element.Id.ToString();
                     var code = GetErrorCode(element, item.SystemName);
                     if (IsNeedExport(code))
@@ -98,7 +101,9 @@ namespace ServiceRevitLib.DataCheck.Mode
                 List<MEPCurve> curves = endElements.OfType<MEPCurve>().ToList();
                 foreach (var mepCurve in curves)
                 {
-                    if (systemName != mepCurve.GetSystemTypeName())
+                    var tempSystem = mepCurve.GetSystemTypeName();
+                    if (tempSystem.IsNullOrEmpty()) continue;
+                    if (systemName != tempSystem)
                     {
                         errorCode = PipeCheckErrorCode.Code_002;
                         break;

+ 3 - 2
Executer/DataCheck/TestCommand.cs

@@ -29,10 +29,11 @@ namespace ServiceRevitLib
                 factory.SetCheckItems("SagaCheck,UnitCheck,FamilyNameCheck,EquipPartLocationCheck,ColumnCheck,ElementRangeCheck,ConnectorCheck,SystemNameCheck,EquipInSpaceCheck,SystemReferEquipCheck,ParameterIntegrityCheck,PipeCheck,XYZOverlapCheck");
                 factory.Check(doc);
                 result = Serialze(factory);
+#if DEBUG
                 string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
                 string path = Path.Combine(@"D:\", $"DataCheck{fileName}.json");
-                //File.WriteAllText(path, result);
-
+                File.WriteAllText(path, result);
+#endif
             }
             catch (Exception e)
             {

+ 1 - 1
Executer/DataExport/JBIM/Component/Duct.cs

@@ -36,7 +36,7 @@ namespace JBIM.Component
         /// <summary>
         /// Connector连接的connectorIds
         /// </summary>
-        public List<BimId> ConnectedIds { get; private set; }
+        public List<BimId> ConnectedIds { get;  set; }
         /// <summary>
         /// 风管形状
         /// </summary>

+ 25 - 0
Executer/DataExport/JBIM/Component/FlexDuct.cs

@@ -0,0 +1,25 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:软风管
+ * 作者:mengxiangge
+ * 创建时间: 2020/5/1711:10:06
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+using JBIM.Definition;
+
+namespace JBIM.Component
+{
+    /// <summary>
+    /// 风管类型
+    /// </summary>
+    [TypeDefiniton(TypeDefinition.FlexDuct)]
+    public class FlexDuct : Duct
+    {
+    }
+}

+ 22 - 0
Executer/DataExport/JBIM/Component/FlexPipe.cs

@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:mengxiangge
+ * 作者:mengxiangge
+ * 创建时间: 2020/5/1711:10:06
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Common;
+using JBIM.Definition;
+
+namespace JBIM.Component
+{
+    [TypeDefiniton(TypeDefinition.FlexPipe)]
+    public class FlexPipe: Pipe
+    {
+    }
+}

+ 1 - 1
Executer/DataExport/JBIM/Component/Pipe.cs

@@ -25,7 +25,7 @@ namespace JBIM.Component
         /// <summary>
         /// Connector连接的connectorIds
         /// </summary>
-        public List<BimId> ConnectedIds { get; private set; }
+        public List<BimId> ConnectedIds { get;  set; }
         ///// <summary>
         ///// connector关联的系统实例
         ///// </summary>

+ 1 - 7
Executer/DataExport/JBIM/Definition/ConnectorShape.cs

@@ -26,11 +26,5 @@ namespace JBIM.Definition
         Rectangle=1,
         Ellipse=2
     }
-
-    public enum ConnectorDomain
-    {
-        DomainUndefined=0,
-        DomainPiping =1,
-        DomainHvac,
-    }
+    
 }

+ 5 - 1
Executer/DataExport/JBIM/Definition/TypeDefinition.cs

@@ -24,9 +24,13 @@ namespace JBIM.Definition
         [Description("Connector")]
         Connector,
         [Description("Duct")]
-        Duct ,
+        Duct,
+        [Description("FlexDuct")]
+        FlexDuct,
         [Description("Pipe")]
         Pipe ,
+        [Description("FlexPipe")]
+        FlexPipe,
         [Description("Space")]
         Space,
         [Description("MepSystem")]

+ 2 - 0
Executer/DataExport/JBIM/JBIM.csproj

@@ -65,6 +65,7 @@
     <Compile Include="Component\ComponentObject.cs" />
     <Compile Include="Component\Connector.cs" />
     <Compile Include="Component\Door.cs" />
+    <Compile Include="Component\FlexDuct.cs" />
     <Compile Include="Component\Duct.cs" />
     <Compile Include="Component\Grid.cs" />
     <Compile Include="Component\Level.cs" />
@@ -74,6 +75,7 @@
     <Compile Include="Component\OtherJoinObject.cs" />
     <Compile Include="Component\Parameter.cs" />
     <Compile Include="Component\ParameterDefinition.cs" />
+    <Compile Include="Component\FlexPipe.cs" />
     <Compile Include="Component\Pipe.cs" />
     <Compile Include="Component\EquipPart.cs" />
     <Compile Include="Component\Equipment.cs" />

BIN
Executer/DataExport/MBIResource/DataCheck/模型检查结果输出格式-模版.xlsx


+ 25 - 37
Executer/DataExport/RevitToJBim/ComponentParse/ParseCore.cs

@@ -32,34 +32,34 @@ namespace RevitToJBim.ComponentParse
     /// </summary>
     public class ParseCore
     {
-       //获取可用的解析类
-       public static List<ParseBase> GetUseParsers()
+        //获取可用的解析类
+        public static List<ParseBase> GetUseParsers()
+        {
+            List<ParseBase> result = new List<ParseBase>();
+            Assembly assembly = Assembly.GetCallingAssembly();
+            Type[] types = assembly.GetTypes();
+            foreach (var type in types)
             {
-                List<ParseBase> result = new List<ParseBase>();
-                Assembly assembly = Assembly.GetCallingAssembly();
-                Type[] types = assembly.GetTypes();
-                foreach (var type in types)
+                if (typeof(ParseBase).IsAssignableFrom(type))
                 {
-                    if (typeof(ParseBase).IsAssignableFrom (type))
-                    {
-                        if (type.IsAbstract || type.IsGenericTypeDefinition)
-                            continue;
-                        var attribute = type.GetCustomAttribute<UsableParseAttribute>();
-                        if (attribute == null)
-                            continue;
-                        var construstor = type.GetConstructor(Type.EmptyTypes);
-                        if (construstor == null)
-                            continue;
-                        if (construstor.Invoke(null) is ParseBase parse)
-                            result.Add(parse);
+                    if (type.IsAbstract || type.IsGenericTypeDefinition)
+                        continue;
+                    var attribute = type.GetCustomAttribute<UsableParseAttribute>();
+                    if (attribute == null)
+                        continue;
+                    var construstor = type.GetConstructor(Type.EmptyTypes);
+                    if (construstor == null)
+                        continue;
+                    if (construstor.Invoke(null) is ParseBase parse)
+                        result.Add(parse);
 
-                    }
                 }
+            }
+
+            return result;
 
-                return result;
+        }
 
-            }
-     
         public static void AttachObject(ComponentObject bimObj, ElementWrapper wrapper)
         {
             bimObj.SourceId = wrapper.SourceId;
@@ -67,21 +67,9 @@ namespace RevitToJBim.ComponentParse
         }
         public static JConnector CreateConnector(Autodesk.Revit.DB.Connector connector)
         {
-            var result= new JConnector();
+            var result = new JConnector();
             result.SourceId = RevitIdGenerator.GetConnectorId(connector);
-            switch (connector.Domain)
-            {
-                case Domain.DomainHvac:
-                {
-                    result.Domain = ConnectorDomain.DomainHvac.ToString();
-                    break;
-                }
-                case Domain.DomainPiping:
-                {
-                    result.Domain = ConnectorDomain.DomainPiping.ToString();
-                    break;
-                }
-            }
+            result.Domain = connector.Domain.ToString();
             result.IsConnected = connector.IsConnected;
             result.Description = connector.Description;
             result.Origin = BimConvert.ConvertToXYZ(connector.Origin);
@@ -104,7 +92,7 @@ namespace RevitToJBim.ComponentParse
         /// <param name="element"></param>
         /// <param name="connectors"></param>
         /// <returns></returns>
-        public static ElementOneToManyRel GetConnectorRels(Element element,List<Autodesk.Revit.DB.Connector> connectors)
+        public static ElementOneToManyRel GetConnectorRels(Element element, List<Autodesk.Revit.DB.Connector> connectors)
         {
             ElementOneToManyRel relMany = new ElementOneToManyRel(element.Id.ToString()) { RelatedObjects = new List<string>() };
             relMany.SetElementType(TypeDefinition.Property_ConnectedIds);

+ 25 - 15
Executer/DataExport/RevitToJBim/ComponentParse/ParseDuct.cs

@@ -28,28 +28,38 @@ namespace RevitToJBim.ComponentParse
     {
         public override List<string> FastIndex()
         {
-            return new List<string>() { typeof(Duct).FullName };
+            return new List<string>() { typeof(Duct).FullName, typeof(FlexDuct).FullName };
         }
         public override bool Match(ElementWrapper wrapper)
         {
-            return wrapper.RefElement is Duct;
+            return wrapper.RefElement is Duct || wrapper.RefElement is FlexDuct;
         }
 
         protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
         {
-            if (!(wrapper.RefElement is Duct duct))
+            if (!(wrapper.RefElement is MEPCurve duct))
             {
                 return null;
             }
             JDuct jDuct = new JDuct();
-            ParseCore.AttachObject(jDuct, wrapper);           
-            var locations = new List<XYZ>();
-            locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().StartPoint()));
-            locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().EndPoint()));
-            jDuct.Location = GeometryLocation.CreateLineLocation(locations);
-            Polygon outLine = new Polygon(locations);
-            jDuct.OutLine.Add(outLine);
+            if (duct is FlexDuct)
+                jDuct = new JBIM.Component.FlexDuct();
+            ParseCore.AttachObject(jDuct, wrapper);
+            try
+            {
+                var locations = new List<XYZ>();
+                locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().StartPoint()));
+                locations.Add(BimConvert.ConvertToXYZ(duct.GetCurve().EndPoint()));
+                jDuct.Location = GeometryLocation.CreateLineLocation(locations);
+                Polygon outLine = new Polygon(locations);
+                jDuct.OutLine.Add(outLine);
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
             context.AddBimObject(jDuct);
+
             //Parameters
             jDuct.Parameters = RevitUtil.GetMEPCurveParameters(duct);
             #region 关联数据处理相关
@@ -64,7 +74,7 @@ namespace RevitToJBim.ComponentParse
             {
                 //Console.WriteLine(e.Message+e.StackTrace);
             }
-            
+
             #endregion
 
             ConnectorProfileType shape = ConnectorProfileType.Invalid;
@@ -84,7 +94,7 @@ namespace RevitToJBim.ComponentParse
             }
             #endregion
 
-            if (shape== ConnectorProfileType.Round)
+            if (shape == ConnectorProfileType.Round)
             {//duct.
                 jDuct.Diameter = duct.Diameter.FtToUse();
             }
@@ -94,17 +104,17 @@ namespace RevitToJBim.ComponentParse
                 jDuct.Height = duct.Height.FtToUse();
             }
 
-            jDuct.Shape = (JDuctShape) (int) shape;
+            jDuct.Shape = (JDuctShape)(int)shape;
             #endregion
             return new List<BimId>() { jDuct.Id };
         }
 
         public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
         {
-            if (!(wrapper.RefElement is Duct duct))
+            if (!(wrapper.RefElement is MEPCurve duct))
             {
                 return null;
-            }   
+            }
             var wrappers = new List<ElementWrapper>() { };
             var connectors = duct.GetConnectors(Autodesk.Revit.DB.Domain.DomainHvac);
             foreach (var connector in connectors)

+ 30 - 19
Executer/DataExport/RevitToJBim/ComponentParse/ParsePipe.cs

@@ -10,6 +10,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Plumbing;
 using JBIM;
 using JBIM.Definition;
@@ -19,7 +20,8 @@ using RevitToJBim.Common;
 using RevitToJBim.ParseData;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.MEP;
-using JPipe=JBIM.Component.Pipe;
+using JPipe = JBIM.Component.Pipe;
+using XYZ = JBIM.Definition.XYZ;
 
 namespace RevitToJBim.ComponentParse
 {
@@ -28,11 +30,11 @@ namespace RevitToJBim.ComponentParse
     {
         public override List<string> FastIndex()
         {
-            return new List<string>() { typeof(Pipe).FullName };
+            return new List<string>() { typeof(Pipe).FullName, typeof(FlexPipe).FullName };
         }
         public override bool Match(ElementWrapper wrapper)
         {
-            return wrapper.RefElement is Pipe;
+            return wrapper.RefElement is Pipe || wrapper.RefElement is FlexPipe;
         }
 
         protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
@@ -42,19 +44,28 @@ namespace RevitToJBim.ComponentParse
              *           2、维护一些构件的关联管理关系,可以放在这个方法中,也可以放在ArrangeRefElements中
              *
              */
-            if (!(wrapper.RefElement is Pipe pipe))
+            if (!(wrapper.RefElement is MEPCurve pipe))
             {
                 return null;
             }
             JPipe jPipe = new JPipe();
+            if (pipe is FlexPipe)
+                jPipe = new JBIM.Component.FlexPipe();
             ParseCore.AttachObject(jPipe, wrapper);
-            jPipe.Diameter =pipe.Diameter.FtToUse();
-            var locations = new List<XYZ>();
-            locations.Add(BimConvert.ConvertToXYZ(pipe.GetCurve().StartPoint()));
-            locations.Add(BimConvert.ConvertToXYZ(pipe.GetCurve().EndPoint()));
-            jPipe.Location = GeometryLocation.CreateLineLocation(locations);
-            Polygon outLine = new Polygon(locations);
-            jPipe.OutLine.Add(outLine);
+            jPipe.Diameter = pipe.Diameter.FtToUse();
+            try
+            {
+                var locations = new List<XYZ>();
+                locations.Add(BimConvert.ConvertToXYZ(pipe.GetCurve().StartPoint()));
+                locations.Add(BimConvert.ConvertToXYZ(pipe.GetCurve().EndPoint()));
+                jPipe.Location = GeometryLocation.CreateLineLocation(locations);
+                Polygon outLine = new Polygon(locations);
+                jPipe.OutLine.Add(outLine);
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
             context.AddBimObject(jPipe);
             //Parameters
             jPipe.Parameters = RevitUtil.GetMEPCurveParameters(pipe);
@@ -73,10 +84,10 @@ namespace RevitToJBim.ComponentParse
             {
                 Console.WriteLine(e.Message + e.StackTrace);
             }
-      
+
             #endregion
             #region Connector连接关系
-            var connectors = pipe.GetConnectors();
+            var connectors = (pipe).GetConnectors(Domain.DomainPiping);
             ElementOneToManyRel relMany = new ElementOneToManyRel(pipeId) { RelatedObjects = new List<string>() };
             relMany.SetElementType(TypeDefinition.Property_ConnectedIds);
             foreach (var refConnector in connectors)
@@ -90,23 +101,23 @@ namespace RevitToJBim.ComponentParse
             }
             #endregion
             #endregion
-            return new List<BimId>(){ jPipe.Id };
+            return new List<BimId>() { jPipe.Id };
         }
 
         public override List<ElementWrapper> ArrangeRefElements(ElementWrapper wrapper, JBimParseContext context)
         {
-            if (!(wrapper.RefElement is Pipe pipe))
+            if (!(wrapper.RefElement is MEPCurve pipe))
             {
                 return null;
             }
             //创建MepSystem
-           // var mepSystemElementWrapper = new ElementWrapper(pipe.MEPSystem);
-            var wrappers=new List<ElementWrapper>() { };
-            var connectors = pipe.GetConnectors();
+            // var mepSystemElementWrapper = new ElementWrapper(pipe.MEPSystem);
+            var wrappers = new List<ElementWrapper>() { };
+            var connectors = pipe.GetConnectors(Domain.DomainPiping);
             foreach (var connector in connectors)
             {
                 wrappers.Add(ParseCore.GetConnectorWrapper(connector));
-            }            
+            }
             return wrappers;
         }
     }

+ 4 - 2
Executer/DataExport/RevitToJBim/ExportDataBuilder.cs

@@ -42,8 +42,10 @@ namespace RevitToJBim
             var sourceSpaces = collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().Where(t=>t.IsSpace()).ToList();
             wrappers.AddRange(sourceSpaces.Select(e => new ElementWrapper(e)));
 
-            wrappers.AddRange(collector.Clone().FilterElements<Pipe>().Select(e => new ElementWrapper(e)));
-            wrappers.AddRange(collector.Clone().FilterElements<Duct>().Select(e => new ElementWrapper(e)));
+            var mepCurves = doc.FilterElements<MEPCurve>().ToList();
+            wrappers.AddRange(mepCurves.Select(e => new ElementWrapper(e)));
+            //wrappers.AddRange(collector.Clone().FilterElements<Pipe>().Select(e => new ElementWrapper(e)));
+            //wrappers.AddRange(collector.Clone().FilterElements<Duct>().Select(e => new ElementWrapper(e)));
             var familyInstances = collector.Clone().FilterElements<FamilyInstance>();
             foreach (FamilyInstance familyInstance in familyInstances)
             {

+ 28 - 20
Executer/DataExport/RevitToJBim/JBimParseContext.cs

@@ -23,7 +23,7 @@ namespace RevitToJBim
     /// <summary>
     /// JBimParseContext解析上下文
     /// </summary>
-    public class JBimParseContext: ParseContext
+    public class JBimParseContext : ParseContext
     {
         public JBimParseContext(List<ParseBase> parsers)
         {
@@ -32,8 +32,8 @@ namespace RevitToJBim
             RelationShips = new List<ElementRelationShip>();
         }
         public RevitToJBimParser Parser { get; private set; }
-        protected BimDocument Document { get;private set; }
-        
+        protected BimDocument Document { get; private set; }
+
         #region 数据缓存相关
 
         private Dictionary<string, BimId> m_RevitIdMap = new Dictionary<string, BimId>();
@@ -65,12 +65,12 @@ namespace RevitToJBim
         }
         public BimId AddBimObject(BimObject obj)
         {
-            var id= this.Document.NewObject(obj)?.Id;
-            if (obj is ComponentObject cObject&&!string.IsNullOrWhiteSpace(cObject.SourceId))
+            var id = this.Document.NewObject(obj)?.Id;
+            if (obj is ComponentObject cObject && !string.IsNullOrWhiteSpace(cObject.SourceId))
             {
                 m_RevitIdMap[cObject.SourceId] = id;
             }
-          return id;
+            return id;
         }
         #endregion
 
@@ -88,24 +88,32 @@ namespace RevitToJBim
         #region 整理document数据
         private void ArrangeBimDocument()
         {
-            #region 关系数据处理
-            /*
-             * 当前关系数据是一个临时数据,需要不全信息之后才能真实使用
-             * 临时数据中,存储的是SourceId的对应关系
-             */
-            foreach (var relationshipBase in RelationShips)
+            try
             {
-                if (relationshipBase.IsProperty)
-                {
-                    UpdateRelationShipInfo(relationshipBase);
-                }
-                else
+                /*
+           * 当前关系数据是一个临时数据,需要不全信息之后才能真实使用
+           * 临时数据中,存储的是SourceId的对应关系
+           */
+                foreach (var relationshipBase in RelationShips)
                 {
-                    var bimRelation = ConvertRelationShipInfo(relationshipBase);
-                    Document.NewObject(bimRelation);
+                    if (relationshipBase.IsProperty)
+                    {
+                        UpdateRelationShipInfo(relationshipBase);
+                    }
+                    else
+                    {
+                        var bimRelation = ConvertRelationShipInfo(relationshipBase);
+                        Document.NewObject(bimRelation);
+                    }
                 }
+                #endregion
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
             }
-            #endregion
+            #region 关系数据处理
+
         }
         /// <summary>
         /// 获取关联对象的BimId

+ 1 - 1
Starter/Starter/Program.cs

@@ -45,7 +45,7 @@ namespace ExportStart
                 path = @"D:\给排水系统图模型第一版V1225.rvt";
                 path = @"E:\1245.rvt";
 
-                path = @"C:\Users\SAGACLOUD\Desktop\北京亚洲金融大厦F9模型文件v3(1).rvt";
+                path = @"C:\Users\SAGACLOUD\Desktop\海天中心项目_AM_T1_21F .rvt";
                 //path = @"D:\安装包\CAD\测试模型\F4测试.rvt";
                 JObject jObject = new JObject();
                 jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");