|
@@ -100,14 +100,6 @@ namespace SAGA.MBI.WinView.Space
|
|
|
}
|
|
|
//本层空间数据缓存
|
|
|
private List<MSpace> m_spacesCache;
|
|
|
-
|
|
|
- public WinCreateSpaces(List<List<XYZ>> wallsData, List<PointPair> virXyzs, List<XYZ> columnsLocation) : this()
|
|
|
- {
|
|
|
- this.m_wallsData = wallsData;
|
|
|
- this.m_virXyzs = virXyzs;
|
|
|
- this.m_columnsLocation = columnsLocation;
|
|
|
-
|
|
|
- }
|
|
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
CanvasDefaultTips();
|
|
@@ -276,17 +268,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
this.btnSave.IsEnabled = true;
|
|
|
Console.WriteLine("Left Down: " + e.GetPosition(canvas));
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 画布鼠标滚轮事件
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void Canvas_OnMouseWheel(object sender, MouseWheelEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 缩放画布
|
|
|
/// </summary>
|
|
@@ -485,17 +467,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 判断点是否在直线上
|
|
|
- /// </summary>
|
|
|
- /// <param name="line"></param>
|
|
|
- /// <param name="point"></param>
|
|
|
- /// <returns></returns>
|
|
|
- //public static bool PointIsInline(SgLine line, Point point)
|
|
|
- //{
|
|
|
- // return PointIsInLine(point, line.StartPoint, line.EndPoint, 3);
|
|
|
- //}
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 判断点是否在直线上
|
|
|
/// </summary>
|
|
@@ -898,34 +870,6 @@ namespace SAGA.MBI.WinView.Space
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private bool CheckLogs()
|
|
|
- {
|
|
|
- List<DocumentChangedLogMode> logs = DocumentChangedLog.LoadLog(MBIControl.ProjectBasePath);
|
|
|
-
|
|
|
- #region 去除无效数据
|
|
|
-
|
|
|
- //根据Id将日志进行分组
|
|
|
- var groupLogsById = logs.GroupBy(t => t.Id);
|
|
|
- foreach (var gl in groupLogsById)
|
|
|
- {
|
|
|
- //日志中一个Id只会存在一个Add和一个Delete,如果两个同时存在则为无效数据
|
|
|
- var count = gl.Count(t =>
|
|
|
- t.Operator == "Add" || t.Operator == "Delete");
|
|
|
- if (count == 2)
|
|
|
- {
|
|
|
- logs.RemoveAll(t => t.Id == gl.Key);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
- //影响空间的类型
|
|
|
- var categorys =
|
|
|
- "OST_MEPSpaceSeparationLines,OST_Walls,OST_RoomSeparationLines,OST_StructuralColumns,OST_Columns";
|
|
|
- var isAddOrModified = logs.Any(t => categorys.IndexOf(t.Category) > -1);
|
|
|
-
|
|
|
- //删除的需要全部遍历一遍去查找类型,但是像模型线之类的非设备信息是无法查找的
|
|
|
- return true;
|
|
|
- }
|
|
|
/// <summary>
|
|
|
/// 创建空间并重新加载到列表
|
|
|
/// </summary>
|
|
@@ -1029,107 +973,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
lbSpaces.ItemsSource = new ObservableCollection<MSpace>(datas);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 将Elements 转换为Jarray数据,便于数据请求
|
|
|
- /// </summary>
|
|
|
- /// <typeparam name="T"></typeparam>
|
|
|
- /// <param name="spaces"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private static JArray ConvertElementsToJArray<T>(List<T> spaces) where T : Element
|
|
|
- {
|
|
|
- JArray infosjobj = new JArray();
|
|
|
-
|
|
|
- spaces.ForEach(s =>
|
|
|
- {
|
|
|
- if (s != null)
|
|
|
- {
|
|
|
- JObject valueJObject = new JObject();
|
|
|
- string bimId = s.GetCloudBIMId();
|
|
|
- valueJObject.Add("BIMID", bimId);
|
|
|
- infosjobj.Add(valueJObject);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- return infosjobj;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 删除冲突的空间
|
|
|
- /// </summary>
|
|
|
- /// <param name="doc"></param>
|
|
|
- private static void DeleteFailuresPreprocessorData(Document doc)
|
|
|
- {
|
|
|
- using (Transaction trans = new Transaction(doc, "删除多余的空间"))
|
|
|
- {
|
|
|
- trans.Start();
|
|
|
- try
|
|
|
- {
|
|
|
- //处理异常显示
|
|
|
- FailureHandlingOptions fho = trans.GetFailureHandlingOptions();
|
|
|
- fho.SetFailuresPreprocessor(new FailuresPreprocessor(false));
|
|
|
- trans.SetFailureHandlingOptions(fho);
|
|
|
- Regex regex = new Regex("^\\d$");
|
|
|
- //对冲突的空间进行删除
|
|
|
- foreach (List<ElementId> elementIds in StaticData.FailuresPreprocessorData)
|
|
|
- {
|
|
|
- var firstElement = doc.GetElement(elementIds.FirstOrDefault());
|
|
|
- //对所有冲突的空间编号进行比较,保留较小编号的空间
|
|
|
- if (firstElement is Autodesk.Revit.DB.Mechanical.Space first)
|
|
|
- {
|
|
|
- foreach (var id in elementIds)
|
|
|
- {
|
|
|
- if (first.Id.IsEqual(id))
|
|
|
- continue;
|
|
|
- var curr = doc.GetElement(id) as Autodesk.Revit.DB.Mechanical.Space;
|
|
|
- if (curr == null) continue;
|
|
|
- // Logs.Log("=============");
|
|
|
- // Logs.Log($"当前空间Id:{id},Num:{curr.Number}");
|
|
|
-
|
|
|
- //如果编号非数字,删其中一个
|
|
|
- if (!regex.IsMatch(first.Number))
|
|
|
- {
|
|
|
- doc.Delete(new List<ElementId>() { first.Id });
|
|
|
-
|
|
|
- first = curr;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!regex.IsMatch(curr.Number))
|
|
|
- {
|
|
|
- doc.Delete(new List<ElementId>() { id });
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (int.Parse(first.Number) > int.Parse(curr.Number))
|
|
|
- {
|
|
|
- // Logs.Log($"1.被删除的空间Id:{id},Num:{first.Number}");
|
|
|
- doc.Delete(new List<ElementId>() { first.Id });
|
|
|
-
|
|
|
- first = curr;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Logs.Log($"2.被删除的空间Id:{id},Num:{curr.Number}");
|
|
|
- doc.Delete(new List<ElementId>() { id });
|
|
|
-
|
|
|
- }
|
|
|
- // Logs.Log("=============");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //提交事务
|
|
|
- trans.Commit();
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- MessageBox.Show(e.Message);
|
|
|
- //回滚事务
|
|
|
- trans.RollBack();
|
|
|
- }
|
|
|
- }
|
|
|
- StaticData.FailuresPreprocessorData.Clear();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 手动删除冲突的空间
|
|
|
/// </summary>
|
|
@@ -1156,10 +1000,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
{
|
|
|
Logs.Log(string.Join("-", elementIds));
|
|
|
//取出空间的服务器信息
|
|
|
- // var requestId = ConvertElementsToJArray(elementIds.Select(doc.GetElement).ToList());
|
|
|
- // if (requestId.Count == 0) continue;
|
|
|
- // var spacesServerInfo = CommonConvert.QueryObjectInfoByIds(m_curFloorId, requestId);
|
|
|
-
|
|
|
+
|
|
|
var spacesServerInfo = GetSpaceFromCacheByIds(elementIds);
|
|
|
//如果返回值小于等于1,自动处理
|
|
|
//如果返回值大于1,则在界面处理
|
|
@@ -1264,29 +1105,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
if (isReCreate) CreateSpaceAndReload(doc, null);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 反射进行墙计算
|
|
|
- /// SAGA.GplotRelationComputerManage已经引用了SAGA.MBI
|
|
|
- /// </summary>
|
|
|
- /// <param name="walls"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private List<List<XYZ>> GroupWallByParallel(List<Wall> walls)
|
|
|
- {
|
|
|
- // List<List<XYZ>> wallData = WallOperationFactory.GroupWallByParallel(walls);
|
|
|
- //下面为上一句代码的反射调用
|
|
|
- var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
|
- Assembly asm = Assembly.LoadFrom(Path.Combine(path, "SAGA.GplotRelationComputerManage.dll"));
|
|
|
- var typeName = "SAGA.GplotRelationComputerManage.ComputerWalls.WallOperationFactory";
|
|
|
- var type = asm.GetType(typeName);
|
|
|
- MethodInfo methodInfo = type.GetMethod("GroupWallByParallel");
|
|
|
- if (methodInfo != null)
|
|
|
- {
|
|
|
- var result = methodInfo.Invoke(null, new object[] { walls }) as List<List<XYZ>>;
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- return new List<List<XYZ>>();
|
|
|
- }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 加载模型数据
|
|
|
/// </summary>
|
|
@@ -1379,15 +1198,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
ShowSpaceProperty(equipment);
|
|
|
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 显示空间属性窗体
|
|
|
- /// </summary>
|
|
|
- /// <param name="space"></param>
|
|
|
- private static void ShowSpaceProperty(string serverId)
|
|
|
- {
|
|
|
- MRevitEquipBase equipment = CommonConvert.QueryObjectById(serverId);
|
|
|
- ShowSpaceProperty(equipment);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private static void ShowSpaceProperty(MRevitEquipBase equipment)
|
|
|
{
|
|
@@ -1508,11 +1319,7 @@ namespace SAGA.MBI.WinView.Space
|
|
|
//创建定时器,以检测所有操作是否全部保存完成
|
|
|
private DispatcherTimer timer;
|
|
|
|
|
|
- private void BtnSaveToRevit_OnClick(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- // m_document.Close(true);
|
|
|
- m_document.Save();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
private void CanvasDefaultTips()
|