|
@@ -5,6 +5,7 @@
|
|
* ==============================================================================*/
|
|
* ==============================================================================*/
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Drawing;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
@@ -31,20 +32,38 @@ namespace SAGA.MBI.Tools
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="fi"></param>
|
|
/// <param name="fi"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public static bool IsEquipment(this FamilyInstance fi)
|
|
|
|
|
|
+ public static bool IsEquipment(this Element element)
|
|
{
|
|
{
|
|
- var family = fi.GetFamily().Name;
|
|
|
|
- return Regex.IsMatch(family, @"^[A-Z]{4}\s*-\s*\S*");
|
|
|
|
|
|
+ bool result = false;
|
|
|
|
+ if (element is Wall wall)
|
|
|
|
+ {//添加幕墙识别
|
|
|
|
+ result = wall.WallType.Kind == WallKind.Curtain;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ if (element is FamilyInstance fi)
|
|
|
|
+ {
|
|
|
|
+ var family = fi.GetFamilyName();
|
|
|
|
+ result = Regex.IsMatch(family, @"^[A-Z]{4}\s*-\s*\S*");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 判断是否为设备部件 设备族为6位
|
|
/// 判断是否为设备部件 设备族为6位
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="fi"></param>
|
|
/// <param name="fi"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public static bool IsEquipmentPart(this FamilyInstance fi)
|
|
|
|
|
|
+ public static bool IsEquipmentPart(this Element element)
|
|
{
|
|
{
|
|
- var family = fi.GetFamily().Name;
|
|
|
|
- return Regex.IsMatch(family, @"^[A-Z]{6}\s*-\s*\S*");
|
|
|
|
|
|
+ bool result = false;
|
|
|
|
+ if (element is FamilyInstance fi)
|
|
|
|
+ {
|
|
|
|
+ var family = fi.GetFamilyName();
|
|
|
|
+ result = Regex.IsMatch(family, @"^[A-Z]{6}\s*-\s*\S*");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 设备mbi设备名称解析
|
|
/// 设备mbi设备名称解析
|
|
@@ -63,10 +82,10 @@ namespace SAGA.MBI.Tools
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="elem"></param>
|
|
/// <param name="elem"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public static bool IsBeacon(this FamilyInstance elem)
|
|
|
|
|
|
+ public static bool IsBeacon(this Element elem)
|
|
{
|
|
{
|
|
- var family = elem.GetFamily().Name;
|
|
|
|
- return (Regex.IsMatch(family, MBIConst.BeaconFamilyName));
|
|
|
|
|
|
+ var family = elem.GetFamilyName();
|
|
|
|
+ return family != null && (Regex.IsMatch(family, MBIConst.BeaconFamilyName));
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -171,38 +190,70 @@ namespace SAGA.MBI.Tools
|
|
/// 族名称的命名规则:ATFC-风机盘管
|
|
/// 族名称的命名规则:ATFC-风机盘管
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public static string GetFamilyCode(this Element fi)
|
|
|
|
|
|
+ public static string GetFamilyCode(this Element element)
|
|
{
|
|
{
|
|
string code = "";
|
|
string code = "";
|
|
- string familyName = fi.GetFamily()?.Name;
|
|
|
|
- if (familyName == null) return code;
|
|
|
|
- //族名称的命名规则:ATFC-风机盘管
|
|
|
|
- int index = familyName.IndexOf('-');
|
|
|
|
- if (index != -1 && index + 1 != familyName.Length)
|
|
|
|
- code = familyName.Substring(0, familyName.IndexOf('-'));
|
|
|
|
- //移除前面和后面的空格
|
|
|
|
- return code.Trim();
|
|
|
|
|
|
+ if (element is FamilyInstance fi)
|
|
|
|
+ {
|
|
|
|
+ string familyName = fi.GetFamilyName();
|
|
|
|
+ if (familyName == null) return code;
|
|
|
|
+ //族名称的命名规则:ATFC-风机盘管
|
|
|
|
+ int index = familyName.IndexOf('-');
|
|
|
|
+ if (index != -1 && index + 1 != familyName.Length)
|
|
|
|
+ code = familyName.Substring(0, familyName.IndexOf('-'));
|
|
|
|
+ //移除前面和后面的空格
|
|
|
|
+ code = code.Trim();
|
|
|
|
+ }
|
|
|
|
+ else if (element is Wall wall)
|
|
|
|
+ {
|
|
|
|
+ if (wall.IsCurtaiWall())
|
|
|
|
+ code = MBIConst.CurtainWallCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return code;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static string GetFamilyName(this Element element)
|
|
|
|
+ {
|
|
|
|
+ return element.GetFamily()?.Name;
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取族的缩略图
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="element"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static Bitmap GetFamilyImage(this Element element)
|
|
|
|
+ {
|
|
|
|
+ return element.GetFamily()?.GetPreviewImage(new System.Drawing.Size(200, 200));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 获取关联的空间
|
|
/// 获取关联的空间
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="fi"></param>
|
|
/// <param name="fi"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public static Space GetReferenceSpace(this FamilyInstance fi, List<Space> spaces = null)
|
|
|
|
|
|
+ public static Space GetReferenceSpace(this Element element, List<Space> spaces = null)
|
|
{
|
|
{
|
|
- Space space = fi.Space;
|
|
|
|
- if (space != null) return space;
|
|
|
|
- if (spaces == null)
|
|
|
|
- spaces = fi.Document.GetSpaces().Where(t => t.IsValidObject).ToList();
|
|
|
|
- var origin1 = fi.GetLocationPointMBIXYZ();
|
|
|
|
- foreach (Space tempSpace in spaces)
|
|
|
|
|
|
+ Space space = null;
|
|
|
|
+ if (element is FamilyInstance fi)
|
|
{
|
|
{
|
|
- //没有Space属性,取定位点,判断定位点所在空间
|
|
|
|
- if (tempSpace.IsPointInSpace(origin1))
|
|
|
|
|
|
+ space = fi.Space;
|
|
|
|
+ if (space != null) return space;
|
|
|
|
+ if (spaces == null)
|
|
|
|
+ spaces = fi.Document.GetSpaces().Where(t => t.IsValidObject).ToList();
|
|
|
|
+ var origin1 = fi.GetLocationPointMBIXYZ();
|
|
|
|
+ foreach (Space tempSpace in spaces)
|
|
{
|
|
{
|
|
- space = tempSpace;
|
|
|
|
- break;
|
|
|
|
|
|
+ //没有Space属性,取定位点,判断定位点所在空间
|
|
|
|
+ if (tempSpace.IsPointInSpace(origin1))
|
|
|
|
+ {
|
|
|
|
+ space = tempSpace;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ }else if (element is Wall wall)
|
|
|
|
+ {
|
|
|
|
+ if (wall.IsCurtaiWall())
|
|
|
|
+ space = null;
|
|
}
|
|
}
|
|
|
|
|
|
return space;
|
|
return space;
|