Browse Source

mxg:IsDeleteSpace 执行结果不符合预期,不知道原因

mengxiangge 5 years ago
parent
commit
153f432065

+ 44 - 21
MBI/SAGA.MBI/ToolsData/ExportAllEquipment.cs

@@ -102,45 +102,55 @@ namespace SAGA.MBI.ToolsData
                     #region 添加表头
 
                     IRow row = sheet.CreateRow(0);
-                    NPOI.SS.UserModel.ICell cell0 = row.CreateCell(0);
+
+                    int i = 0;
+                    NPOI.SS.UserModel.ICell cell0 = row.CreateCell(i);
                     cell0.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell0.SetCellValue("楼层名称");
 
-                    ICell cell1 = row.CreateCell(1);
+                    ICell cell1 = row.CreateCell(++i);
                     cell1.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell1.SetCellValue("类型");
 
-                    ICell cell2 = row.CreateCell(2);
+                    ICell cell2 = row.CreateCell(++i);
+                    cell2.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell2.SetCellValue("物理世界设备类名称");
+
+                    cell2 = row.CreateCell(++i);
                     cell2.SetCellType(NPOI.SS.UserModel.CellType.String);
-                    cell2.SetCellValue("族名称");
+                    cell2.SetCellValue("模型中的设备族名称");
 
-                    ICell cell3 = row.CreateCell(3);
+                    cell2 = row.CreateCell(++i);
+                    cell2.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell2.SetCellValue("模型中的设备类型名称");
+
+                    ICell cell3 = row.CreateCell(++i);
                     cell3.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell3.SetCellValue("物理世界Id");
 
-
-                    ICell cell4 = row.CreateCell(4);
+                    ICell cell4 = row.CreateCell(++i);
                     cell4.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell4.SetCellValue("模型中的Id");
 
-                    ICell cell5 = row.CreateCell(5);
+                    ICell cell5 = row.CreateCell(++i);
                     cell5.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell5.SetCellValue("设备的本地名称");
 
-                    ICell cell6 = row.CreateCell(6);
+                    ICell cell6 = row.CreateCell(++i);
                     cell6.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell6.SetCellValue("设备的本地编码");
 
-                    ICell cell7 = row.CreateCell(7);
+                    ICell cell7 = row.CreateCell(++i);
                     cell7.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell7.SetCellValue("设备所在空间的名称");
 
-                    ICell cell8 = row.CreateCell(8);
+                    ICell cell8 = row.CreateCell(++i);
                     cell8.SetCellType(NPOI.SS.UserModel.CellType.String);
                     cell8.SetCellValue("设备所在空间的模型Id");
 
                     #endregion
 
+                    var doc=context.OpenDocument();
                     Action<MEquipment, string> action = (equip, type) =>
                     {
                         string family = equip.EquipClassCode + "-" + equip.Family?.Name;
@@ -149,34 +159,46 @@ namespace SAGA.MBI.ToolsData
                         index++;
 
                         row = sheet.CreateRow(index);
-
-                        ICell cell = row.CreateCell(0, NPOI.SS.UserModel.CellType.String);
+                        i = 0;
+                        ICell cell = row.CreateCell(i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(context.MFloor.ToString());
 
-                        cell = row.CreateCell(1, NPOI.SS.UserModel.CellType.String);
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(type);
 
-                        cell = row.CreateCell(2, NPOI.SS.UserModel.CellType.String);
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(family);
 
-                        cell = row.CreateCell(3, NPOI.SS.UserModel.CellType.String);
+                        var element = doc.GetElement(bimid);
+                        if (element != null)
+                        {
+                            var familyName = element.GetFamilyName();
+                            var familyTypeName = element.GetFamilySymbol().Name;
+                            cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
+                            cell.SetCellValue(familyName);
+
+                            cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
+                            cell.SetCellValue(familyTypeName);
+                        }
+
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(id);
 
-                        cell = row.CreateCell(4, NPOI.SS.UserModel.CellType.String);
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(bimid);
 
-                        cell = row.CreateCell(5, NPOI.SS.UserModel.CellType.String);
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(equip.LocalName);
 
-                        cell = row.CreateCell(6, NPOI.SS.UserModel.CellType.String);
+                        cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                         cell.SetCellValue(equip.LocalId);
 
                         if (equip.MSpace != null)
                         {
-                            cell = row.CreateCell(7, NPOI.SS.UserModel.CellType.String);
+                            cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                             cell.SetCellValue(equip.MSpace.ToString());
 
-                            cell = row.CreateCell(8, NPOI.SS.UserModel.CellType.String);
+                            cell = row.CreateCell(++i, NPOI.SS.UserModel.CellType.String);
                             cell.SetCellValue(equip.MSpace.BimID.GetBIMID());
                         }
                         
@@ -197,6 +219,7 @@ namespace SAGA.MBI.ToolsData
                     //{
                     //    action(space, "空间");
                     //}
+                    doc.CloseDocSimple();
                 }
 
                 #endregion

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

@@ -190,8 +190,9 @@ namespace SAGA.RevitUtils.Extends
             double perimeter = space.Perimeter;
             //面积
             double area = space.Area;
+            double volume = space.Volume;
             //空间比较特殊,周长为零就相当于删除
-            return  (perimeter.IsZero()||area.IsZero());
+            return (perimeter.IsZero()) || (area.IsZero()) || (volume.IsZero());
         }
 
     }