Browse Source

mxg:导出空间添加面积和周长约束

mengxiangge 5 years ago
parent
commit
fc6d158ef9

+ 0 - 13
MBI/Menu/Tool.xml

@@ -9,19 +9,6 @@
     <Modules>Tool</Modules>
   </Tab>
   <Panel PanelName="工具" GroupFlag="True" GroupImage="" RevitVer="R14,R15,R16,R17"  ButtonStyles="Large">
-
-    <Button ButtonStyles="Large">
-      <ButtonName>ToolCommand.DeleteZeroSpaceCommand</ButtonName>
-      <ButtonText>删除本层Zero空间</ButtonText>
-      <ImageName>1、打开楼层模型</ImageName>
-      <DllName>..\OutputDll\ToolCommand.dll</DllName>
-      <ClassName>ToolCommand.DeleteZeroSpaceCommand</ClassName>
-      <ToolTip>删除本层Zero空间。</ToolTip>
-      <LongDescription>删除本层Zero空间。</LongDescription>
-      <ToolTipImage></ToolTipImage>
-      <MenuTab>Tool_W</MenuTab>
-      <Modules>Tool</Modules>
-    </Button>
     <Button ButtonStyles="Large">
       <ButtonName>ToolCommand.ExportCategoriesCommand</ButtonName>
       <ButtonText>导出所有的设备类别</ButtonText>

+ 5 - 0
MBI/SAGA.MBI/Common/MBIConst.cs

@@ -20,6 +20,11 @@ namespace SAGA.MBI.Common
     /// </summary>
     public class MBIConst
     {
+        //最少空间的面积. 0.4m  削减因子: 1
+        public static readonly double SpacePerimeterTolerance = Math.Pow(0.4 * 1000 / 304.8, 2) / 1;
+        //最小空间的周长. 0.4m  削减因子: 1
+        public static readonly double SpaceAreaTolerance = (0.4 * 1000 / 304.8 * 4) / 1;
+
         public static readonly string ManageCur = "ManageCurLocalize.json";
         public static readonly string MBIAssistDBName = "MBIAssistData.db";
         public static readonly string MBIAssistDBVersion = "SqliteVersion.xml";

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

@@ -17,6 +17,7 @@ using NPOI.SS.Formula.Functions;
 using SAGA.DotNetUtils;
 using SAGA.DotNetUtils.Extend;
 using SAGA.MBI.Common;
+using SAGA.MBI.Extend;
 using SAGA.RevitUtils.Extends;
 
 namespace SAGA.MBI.Tools

+ 37 - 0
MBI/SAGA.MBI/Extend/SpaceExtend.cs

@@ -0,0 +1,37 @@
+/* ==============================================================================
+ * 功能描述:SpaceExtend  
+ * 创 建 者:Garrett
+ * 创建日期:2019/12/6 12:02:26
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB.Mechanical;
+using SAGA.DotNetUtils.Extend;
+using SAGA.MBI.Common;
+
+namespace SAGA.MBI.Extend
+{
+    /// <summary>
+    /// SpaceExtend
+    /// </summary>
+    public static class SpaceExtend
+    {
+        /// <summary>
+        /// 手动删除的空间,仅在明细表中可见
+        /// </summary>
+        /// <param name="space"></param>
+        /// <returns></returns>
+        public static bool IsDeleteSpace(this Space space)
+        {
+            //周长
+            double perimeter = space.Perimeter;
+            //面积
+            double area = space.Area;
+            //空间比较特殊,周长为零就相当于删除
+            return (perimeter.IsZero(MBIConst.SpacePerimeterTolerance)) || (area.IsZero(MBIConst.SpaceAreaTolerance));
+        }
+    }
+}

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

@@ -88,7 +88,7 @@ namespace SAGA.MBI.Interaction
                 jsonStr = db.ToJsonString(sagaName);
             }
             //测试使用
-            //File.WriteAllText(@"c:\" + key, jsonStr);
+            File.WriteAllText(@"D:\" + sagaName+".txt", jsonStr);
             byte[] result = null;
             if (!string.IsNullOrEmpty(jsonStr))
             {

+ 1 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -285,6 +285,7 @@
     <Compile Include="Common\TryCatchWrapper.cs" />
     <Compile Include="Common\WaitingView.cs" />
     <Compile Include="DataArrange\DalInfoCode.cs" />
+    <Compile Include="Extend\SpaceExtend.cs" />
     <Compile Include="Gplot\GplotFileItem.cs" />
     <Compile Include="Gplot\GplotWatch.cs" />
     <Compile Include="Gplot\JsonConfig.cs" />

+ 1 - 0
MBI/SAGA.MBI/ToolsData/DelZeroSpace.cs

@@ -18,6 +18,7 @@ using Autodesk.Revit.DB.Mechanical;
 using SAGA.DotNetUtils;
 using SAGA.DotNetUtils.Logger;
 using SAGA.MBI.DataArrange;
+using SAGA.MBI.Extend;
 using SAGA.MBI.Tools;
 using SAGA.RevitUtils.Extends;
 

+ 2 - 14
MBI/SAGA.RevitUtils/Extends/SpaceExtend.cs

@@ -179,20 +179,8 @@ namespace SAGA.RevitUtils.Extends
         {
             return space.GetTopLevel().Elevation + space.GetTopOffSet();
         }
-        /// <summary>
-        /// 手动删除的空间,仅在明细表中可见
-        /// </summary>
-        /// <param name="space"></param>
-        /// <returns></returns>
-        public static bool IsDeleteSpace(this Space space)
-        {
-            //周长
-            double perimeter = space.Perimeter;
-            //面积
-            double area = space.Area;
-            //空间比较特殊,周长为零就相当于删除
-            return (perimeter.IsZero()) || (area.IsZero());
-        }
+
+        
 
     }
 }

+ 0 - 27
MBI/ToolCommand/Command.cs

@@ -13,33 +13,6 @@ using System.IO;
 namespace ToolCommand
 {
     /// <summary>
-    /// 批量删除无用的空间
-    /// </summary>
-    [Transaction(TransactionMode.Manual)]
-    [Regeneration(RegenerationOption.Manual)]
-    public class DeleteZeroSpaceCommand : ExternalCommand
-    {
-        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {
-            try
-            {
-                int count = 0;
-                bool tip = MessageShowBase.Question("确定要删除本层周长为零的空间?\r\n是:修正本楼层\r\n否:取消修正。");
-                if (tip)
-                {
-                    count = DelZeroSpace.Operate();
-                    MessageShowBase.Infomation($"此次操作共删除{count}个空间");
-                }
-            }
-            catch (Exception e)
-            {
-                MessageShow.Show(e);
-                return Result.Cancelled;
-            }
-            return Result.Succeeded;
-        }
-    }
-    /// <summary>
     /// 导出类别
     /// </summary>
     [Transaction(TransactionMode.Manual)]

+ 0 - 58
MBI/ToolCommand/DelZeroSpace.cs

@@ -1,58 +0,0 @@
-/* ==============================================================================
- * 功能描述:删除周长为零的空间
- * 创 建 者:Garrett
- * 创建日期:2018/7/12 14:25:17
- * ==============================================================================*/
-
-using System;
-using System.Linq;
-using Autodesk.Revit.DB;
-using SAGA.DotNetUtils.Others;
-using SAGA.RevitUtils.Extends;
-
-namespace ToolCommand
-{
-    /// <summary>
-    /// CheckEquipCategory
-    /// </summary>
-    public class DelZeroSpace
-    {
-        /// <summary>
-        /// 检查并处理
-        /// </summary>
-        /// <param name="floor"></param>
-        /// <returns></returns>
-        public static int Operate()
-        {
-            int count = 0;
-            try
-            {
-                var doc = ExternalDataWrapper.Current.Doc;
-                using (Transaction trans = new Transaction(doc, "删除"))
-                {
-                    trans.Start();
-                    try
-                    {
-                        var spaces = doc.GetSpaces().Where(t => t.IsDeleteSpace()).ToList();
-                        count = spaces.Count;
-                        doc.Delete(spaces.Select(t => t.Id).ToList());
-                        trans.Commit();
-                    }
-                    catch (Exception)
-                    {
-                        trans.RollBack();
-
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                MessageShowBase.Show(e);
-            }
-            finally
-            {
-            }
-            return count;
-        }
-    }
-}

+ 0 - 1
MBI/ToolCommand/ToolCommand.csproj

@@ -66,7 +66,6 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Command.cs" />
-    <Compile Include="DelZeroSpace.cs" />
     <Compile Include="ExportAllCategory.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RoomDataToSpaceCommand.cs" />