/* ==============================================================================
* 功能描述:SagaCheck
* 创 建 者:Garrett
* 创建日期:2019/6/11 16:09:09
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using SAGA.RevitUtils.Extends;
using ServiceRevitLib.Extend;
using ServiceRevitLib.Mode;
namespace ServiceRevitLib.DataCheck.Mode
{
///
/// SagaCheck
///
class EquipInSpaceCheck : CheckBase
{
public override void Check()
{
try
{
base.Check();
#region
var document = m_Doc;
var elements = document.GetEqEcElements();
var rspaces = document.GetSpaces().Where(t => t.IsValidObject).ToList();
foreach (Element fi in elements)
{
var result = GetCheckResult(fi, rspaces);
Content.Add(result);
}
#endregion
}
catch (Exception e)
{
Result = ResultState.Failure;
ResultMsg = $"{e.Message}\r\n{e.StackTrace}";
}
}
///
/// 获取检测结果
///
///
///
private EquipInSpaceCheckResult GetCheckResult(Element fi, List spaces)
{
var result = new EquipInSpaceCheckResult();
result.FamilyName = fi.GetFamilyName();
result.Id = fi.Id.ToString();
var space = fi.GetReferenceSpace(spaces);
if (space != null)
{
result.SpaceId = space.Id.ToString();
result.Result = ResultState.Success;
}
else
{
result.Result = ResultState.Failure;
result.ResultMsg = "请检查设备是否在空间中";
}
return result;
}
}
}