Forráskód Böngészése

xls:调整多边形显示结构

xulisong 5 éve
szülő
commit
db9f017dbb

+ 18 - 5
JBIM/RevitToJBim/Common/Converter.cs

@@ -37,10 +37,21 @@ namespace RevitToJBim.Common
         /// 将点转换成毫米单位形式
         /// </summary>
         /// <param name="xyz"></param>
+        /// <param name="ignoreZ">转换是否忽略Z</param>
         /// <returns></returns>
-        public static XYZ ConvertToXYZ(Autodesk.Revit.DB.XYZ xyz)
+        public static XYZ ConvertToXYZ(Autodesk.Revit.DB.XYZ xyz,bool ignoreZ=false)
         {
-            return new XYZ() {X = FtToUse(xyz.X), Y = FtToUse(xyz.Y), Z = FtToUse(xyz.Z), };
+            var result = new XYZ()
+            {
+                X = FtToUse(xyz.X),
+                Y = FtToUse(xyz.Y)
+            };
+            if (!ignoreZ)
+            {
+                result.Z = FtToUse(xyz.Z);
+            }
+
+            return result;
         }
         /// <summary>
         /// 转换成向量
@@ -54,11 +65,13 @@ namespace RevitToJBim.Common
         /// <summary>
         /// 将点转换成毫米单位形式
         /// </summary>
-        /// <param name="xyzes"></param>
+        /// <param name="xyzs"></param>
+        /// <param name="ignoreZ">转换是否忽略Z</param>
         /// <returns></returns>
-        public static List<XYZ> ConvertToXYZs(List<Autodesk.Revit.DB.XYZ> xyzs)
+        public static List<XYZ> ConvertToXYZs(List<Autodesk.Revit.DB.XYZ> xyzs, bool ignoreZ=false)
         {
-            return xyzs.Select(xyz=>ConvertToXYZ(xyz)).ToList();
+            return xyzs.Select(xyz=>ConvertToXYZ(xyz, ignoreZ)).ToList();
         }
+       
     }
 }

+ 1 - 1
JBIM/RevitToJBim/Common/RevitUtil.cs

@@ -95,7 +95,7 @@ namespace RevitToJBim.Common
         /// <summary>
         /// 获取设备设施的参数
         /// </summary>
-        /// <param name="fi"></param>
+        /// <param name="space"></param>
         /// <returns></returns>
         public static List<Parameter> GetSpaceParameters(Space space)
         {

+ 38 - 0
JBIM/RevitToJBim/Common/StandardUtil.cs

@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:StandardUtil
+ * 作者:xulisong
+ * 创建时间: 2019/6/27 11:25:35
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JBIM.Definition;
+using SAGA.DotNetUtils.Extend;
+
+namespace RevitToJBim.Common
+{
+    /// <summary>
+    /// 标准整理工具
+    /// </summary>
+    public static class StandardUtil
+    {
+        public static void ArrangeLoop(Polygon polygon)
+        {
+            if (polygon.Count>=2)
+            {
+                var firstPoint = polygon[0];
+                var lastPoint = polygon[polygon.Count - 1];
+                if (!firstPoint.X.IsEqual(lastPoint.X) || !firstPoint.Y.IsEqual(lastPoint.Y) ||
+                    !firstPoint.Z.IsEqual(lastPoint.Z))
+                {
+                    polygon.Add(firstPoint);
+                }
+               
+            }
+        }
+    }
+}

+ 1 - 0
JBIM/RevitToJBim/ComponentParse/ParseColumn.cs

@@ -44,6 +44,7 @@ namespace RevitToJBim.ComponentParse
             if (polygonPath != null && polygonPath.Any())
             {
                 Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
+                StandardUtil.ArrangeLoop(outLine);
                 jObject.OutLine.Add(outLine);
             }
             context.AddBimObject(jObject);          

+ 1 - 1
JBIM/RevitToJBim/ComponentParse/ParseDoor.cs

@@ -50,7 +50,7 @@ namespace RevitToJBim.ComponentParse
             var polygonPath = RevitUtil.GetWindowDoorLocation(fi);
             if (polygonPath != null && polygonPath.Any())
             {
-                Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
+                Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath,true));
                 jObject.OutLine.Add(outLine);
             }
             jObject.HandDirection = BimConvert.ConvertToDirection(fi.HandOrientation);

+ 2 - 2
JBIM/RevitToJBim/ComponentParse/ParseSpace.cs

@@ -85,10 +85,10 @@ namespace RevitToJBim.ComponentParse
                         }                 
                         #endregion
 
-                    }
-
+                    }                 
                     if (outLine.Any())
                     {
+                        StandardUtil.ArrangeLoop(outLine);
                         bimObject.OutLine.Add(outLine);
                     }
 

+ 3 - 1
JBIM/RevitToJBim/ComponentParse/ParseWall.cs

@@ -42,9 +42,11 @@ namespace RevitToJBim.ComponentParse
             context.AddBimObject(jObject);
             jObject.Location = ParseCore.GetLocation(wall.Location);
             var polygons = RevitUtil.GetWallPolygon(wall);
+            //是否保持z为0的转换;
             foreach (var polygon in polygons)
             {               
-                var outLine = new Polygon(BimConvert.ConvertToXYZs(polygon));
+                var outLine = new Polygon(BimConvert.ConvertToXYZs(polygon,true));
+                StandardUtil.ArrangeLoop(outLine);
                 jObject.OutLine.Add(outLine);
             }
 

+ 1 - 1
JBIM/RevitToJBim/ComponentParse/ParseWindow.cs

@@ -50,7 +50,7 @@ namespace RevitToJBim.ComponentParse
             var polygonPath = RevitUtil.GetWindowDoorLocation(fi);
             if (polygonPath != null && polygonPath.Any())
             {
-                Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath));
+                Polygon outLine = new Polygon(BimConvert.ConvertToXYZs(polygonPath,true));
                 jObject.OutLine.Add(outLine);
             }
            

+ 1 - 0
JBIM/RevitToJBim/RevitToJBim.csproj

@@ -61,6 +61,7 @@
   <ItemGroup>
     <Compile Include="Common\CategoryGenerator.cs" />
     <Compile Include="Common\Converter.cs" />
+    <Compile Include="Common\StandardUtil.cs" />
     <Compile Include="Extension\CurveExtension.cs" />
     <Compile Include="Common\ElementWrapperFactory.cs" />
     <Compile Include="Common\ExceptionUtil.cs" />