123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using Autodesk.Revit.DB;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- using SAGA.RevitUtils;
- using SAGA.MBI.Tools;
- using System.Text.RegularExpressions;
- namespace SAGA.GplotRelationComputerManage
- {
- /// <summary>
- /// 系统导出设置
- /// </summary>
- public class SystemParseSetting
- {
- public SystemParseSetting(GplotOptions options)
- {
- //GplotOptions = options;
- //var relationType = RelationTypeManager.GetRelationTypeItem(options.);
- }
- public SystemParseSetting(RelationTypeShell relationShell)
- {
- RelationTypeShell = relationShell;
- Domain = relationShell.IsPipeSystem() ? Domain.DomainPiping : Domain.DomainHvac;
- }
- ///// <summary>
- ///// 图相关设置
- ///// </summary>
- //public GplotOptions GplotOptions { get; set; }
- /// <summary>
- /// 关系类型相关
- /// </summary>
- public RelationTypeShell RelationTypeShell { get;private set; }
- /// <summary>
- /// 使用域枚举
- /// </summary>
- public Domain Domain { get;private set; }
- #region 设置相关信息
- /*
- * 1、确定边界:
- * 哪些确定成点标记,哪些确定成边标记【用以处理非点标记甄别】
- * 2、确定遇到什么情况断开
- *
- * 3、确定那些事旁通边
- */
- #endregion
- /// <summary>
- /// 判断是否是节点标记
- /// </summary>
- /// <param name="element"></param>
- /// <returns></returns>
- public bool IsForkNode(Element element)
- {
- Domain domain = Domain;
- var connectors = element.GetConnectors(domain);
- return connectors.Count > 2;
- }
- public List<JoinItem> GetJoinItems(Element element,List<int> usedIds)
- {
- List<JoinItem> joinItems = new List<JoinItem>();
- Domain domain = Domain;
- var connectors = element.GetConnectors(domain);
- foreach (var connector in connectors)
- {
- if (connector.IsLogical())
- continue;
- if (!(element is MEPCurve||connector.IsConnected))
- {
- continue;
- }
- if (IgnoreConnector(connector))
- continue;
- if (!connector.IsConnected)
- {
- joinItems.Add(new JoinItem(connector,null));
- }
- else
- {
- foreach (Connector refConnector in connector.AllRefs)
- {
- if (refConnector.IsLogical() || refConnector.Owner.Id == element.Id || usedIds.Any(id => refConnector.Owner.Id.IntegerValue == id))
- continue;
- if (IgnoreConnector(refConnector))
- continue;
- joinItems.Add(new JoinItem(connector, refConnector));
- }
- }
-
- }
- return joinItems;
- }
- /// <summary>
- /// 标识元素是否是设备
- /// </summary>
- /// <param name="element"></param>
- /// <returns></returns>
- public bool IsEquipment(Element element)
- {
- if (!(element is FamilyInstance fi))
- {
- return false;
- }
- return MBIInfoUtil.IsEquipment(element);
- }
- /// <summary>
- /// 无用边,节点可连通
- /// </summary>
- /// <param name="edge"></param>
- /// <returns></returns>
- public bool UselessEdge(ElementsEdge edge)
- {
- //如果该边的断点含有空点,则证明是虚拟设备
- if (edge.RealStart.IsEmpty() || edge.RealEnd.IsEmpty())
- return false;
- if (edge.RealStart.GetDisableCombine() || edge.RealEnd.GetDisableCombine())
- return false;
- if (edge.RealStart.RefData.Any(e => !e.IsWaterComponment()) ||
- edge.RealEnd.RefData.Any(e => !e.IsWaterComponment()))
- return false;
- return edge.RefData.All(e => e.IsWaterComponment());
- }
- /// <summary>
- /// 忽略的连接关系
- /// </summary>
- /// <param name="connector"></param>
- /// <returns></returns>
- public bool IgnoreConnector(Connector connector)
- {
- bool result = false;
- do
- {
- Element owner = connector.Owner;
- #region 通用判断
- if (owner is MEPCurve mepCurve)
- {
- string typeName = mepCurve.GetSystemTypeName();
- result = !RelationTypeShell.IsMatchSystem(typeName);
- break;
- }
- if (SystemCalcUtil.IsStartValve(owner))
- {
- result = Regex.IsMatch(connector.Description, AppSetting.EndFlag);// connector.Description != GplotOptions.ValveConnectorDescription;
- break;
- }
- #endregion
- if (!owner.IsWaterComponment())
- {
- var mepCurves= owner.GetFirstElements<MEPCurve>(connector);
- if (mepCurves.Any())
- {
- string typeName = (mepCurves[0] as MEPCurve).GetSystemTypeName();
- result = !RelationTypeShell.IsMatchSystem(typeName);// !GplotOptions.MatchSystemType(typeName);
- }
- break;
- }
- } while (false);
- return result;
- }
- #region 制定特殊阀门判断
- /// <summary>
- /// 判断制定元素是否是特定阀门
- /// </summary>
- /// <param name="element"></param>
- /// <returns></returns>
- public bool IsSpecialValve(Element element)
- {
- if(element is FamilyInstance fi)
- {
- var name = fi.GetFamily().Name;
- return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
- }
- return false;
- }
- #endregion
- }
- }
|