12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- """system calc utils.
- 1. get connectors where model_id='@model_id' and belong_type='Equipment' and mep_system_type='@system_name'
- 2. get path start with connector,end with triple ,cross,equipment,end
- """
- from systemrelation import revit_const
- from functools import cmp_to_key
- def path2edge(elements):
- """
- Convert path to GraphtEdge
- :param elements:
- :return:
- """
- pass
- def graph_arrange(graph):
- """
- Combine Vertex that connect to virtul Vertex
- :param graph:
- :return:
- """
- pass
- def connector_sort(connector1, connector2):
- """Use Define Sort rule"""
- dic = {revit_const.EQUIPMENT: 0, revit_const.COMPONENT: 1, revit_const.OTHER: 2, revit_const.PIPE: 3,
- revit_const.DUCT: 4}
- x = dic[connector1.belong_type]
- y = dic[connector2.belong_type]
- return 1 if x > y else -1
- def sort_connectors(connectors):
- """Sort Connector order by Equipment>EquipPart>Other>Pipe>Duct"""
- return sorted(connectors, key=cmp_to_key(lambda x,y:connector_sort(x,y)))
- def is_break_condition(element):
- """Path end Condition."""
- res = element.type in revit_const.FACILITY
- return res
- def dic2obj(d):
- """Convert Dict to Object.
- """
- top = type('new', (object,), d)
- seqs = tuple, list, set, frozenset
- for i, j in d.items():
- if isinstance(j, dict):
- setattr(top, i, dic2obj(j))
- elif isinstance(j, seqs):
- setattr(top, i,
- type(j)(dic2obj(sj) if isinstance(sj, dict) else sj for sj in j))
- else:
- setattr(top, i, j)
- return top
- def list_to_dict(lis):
- ids = [idx.id for idx in lis]
- dic = dict(zip(ids, lis))
- return dic
- def add_attr_is_used(x):
- """"""
- x.is_used=False
- return x
|