|
@@ -0,0 +1,96 @@
|
|
|
+/* ==============================================================================
|
|
|
+ * 功能描述:删除周长为零的空间
|
|
|
+ * 创 建 者:Garrett
|
|
|
+ * 创建日期:2018/7/12 14:25:17
|
|
|
+ * ==============================================================================*/
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using SAGA.DotNetUtils.Others;
|
|
|
+using SAGA.MBI.Calc;
|
|
|
+using SAGA.MBI.Model;
|
|
|
+using SAGA.MBI.RequestData;
|
|
|
+using SAGA.MBI.WinView.Upload;
|
|
|
+using Autodesk.Revit.DB;
|
|
|
+using Autodesk.Revit.DB.Mechanical;
|
|
|
+using SAGA.DotNetUtils;
|
|
|
+using SAGA.DotNetUtils.Logger;
|
|
|
+using SAGA.MBI.DataArrange;
|
|
|
+using SAGA.MBI.Tools;
|
|
|
+using SAGA.RevitUtils.Extends;
|
|
|
+
|
|
|
+namespace SAGA.MBI.ToolsData
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// CheckEquipCategory
|
|
|
+ /// </summary>
|
|
|
+ public class DelZeroSpace
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 检查并处理所有楼层
|
|
|
+ /// </summary>
|
|
|
+ public static int OperateAll()
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ var floors = DalUploadFloor.GetHasFileFloors();
|
|
|
+ foreach (UploadFloor floor in floors)
|
|
|
+ {
|
|
|
+ count+=Operate(floor.MFloor);
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 只处理当前楼层
|
|
|
+ /// </summary>
|
|
|
+ public static int OperateCurFloor()
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
|
|
|
+ if (floor != null)
|
|
|
+ count=Operate(floor);
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 检查并处理
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="floor"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static int Operate(MFloor floor)
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ var context = DalCommon.DownLoadCouldData(floor);
|
|
|
+ context.OpenDocument();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var doc = context.RevitDoc;
|
|
|
+ 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
|
|
|
+ {
|
|
|
+ context.RevitDoc.CloseDoc();
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|