|
@@ -17,6 +17,7 @@ MEPCURVE=[DUCT,PIPE]
|
|
|
|
|
|
from functools import cmp_to_key
|
|
|
import vg
|
|
|
+import json
|
|
|
|
|
|
|
|
|
def path2edge(elements):
|
|
@@ -63,13 +64,18 @@ def dic2obj(d):
|
|
|
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):
|
|
|
+ j0 = j
|
|
|
+ try:
|
|
|
+ j0 = json.loads(j0)
|
|
|
+ except Exception as e:
|
|
|
+ pass
|
|
|
+ if isinstance(j0, dict):
|
|
|
+ setattr(top, i, dic2obj2(j0))
|
|
|
+ elif isinstance(j0, seqs):
|
|
|
setattr(top, i,
|
|
|
- type(j)(dic2obj(sj) if isinstance(sj, dict) else sj for sj in j))
|
|
|
+ type(j0)(dic2obj2(sj) if isinstance(sj, dict) else sj for sj in j0))
|
|
|
else:
|
|
|
- setattr(top, i, j)
|
|
|
+ setattr(top, i, j0)
|
|
|
return top
|
|
|
|
|
|
|
|
@@ -127,7 +133,6 @@ def get_dicdata(sql,dic):
|
|
|
:return:
|
|
|
"""
|
|
|
data=test.get_data(sql)
|
|
|
- print(data)
|
|
|
dic_data=[dict(zip(dic,item)) for item in data]
|
|
|
return list(dic_data)
|
|
|
def get_project_models(project_id):
|
|
@@ -286,7 +291,6 @@ def get_connectors_data(model_id, system_name, domain):
|
|
|
"""Cache all connector from Db。"""
|
|
|
connector_data=[]
|
|
|
connector_sql = "SELECT * FROM revit.connector where model_id='%s' and mep_system_type='%s' and domain='%s'" % (model_id,system_name,domain)
|
|
|
- print(connector_sql)
|
|
|
CONNECTOR_KEYS = [
|
|
|
'id',
|
|
|
'model_id',
|
|
@@ -320,11 +324,15 @@ def save_project_data(project_graph,project_id):
|
|
|
# Create
|
|
|
block_id=0
|
|
|
for g in project_graph.groupedsystemgraphs:
|
|
|
+ print("g")
|
|
|
for s in g.systemgraphs:
|
|
|
+ print("s")
|
|
|
for e in s.system_edges:
|
|
|
- save_edge_data(e, block_id)
|
|
|
+ print("e")
|
|
|
+ #save_edge_data(e, block_id)
|
|
|
for e in g.connectedges:
|
|
|
- save_edge_data(e,block_id)
|
|
|
+ print("e2")
|
|
|
+ #save_edge_data(e,block_id)
|
|
|
block_id+=1
|
|
|
def save_edge_data(edge,block_id):
|
|
|
"""
|
|
@@ -542,7 +550,6 @@ class FloorGraph:
|
|
|
self.get_path(connector, system_graph, graph_next_connectors)
|
|
|
if len(system_graph.system_edges) != 0:
|
|
|
self.system_graphs.append(system_graph)
|
|
|
- print("Next loop:",connector.source_id)
|
|
|
return self.system_graphs
|
|
|
|
|
|
def get_path(self, connector, system_graph, graph_next_connectors):
|
|
@@ -575,7 +582,6 @@ class FloorGraph:
|
|
|
edge_elements.append(next_element)
|
|
|
other_connectors = self.get_other_connectors(next_connector)
|
|
|
if is_break_condition(next_element) or len(other_connectors) != 1:
|
|
|
- print(next_connector.source_id)
|
|
|
next_connector.is_used = True
|
|
|
if(len(other_connectors) != 1):
|
|
|
graph_next_connectors.extend(other_connectors)
|
|
@@ -620,7 +626,7 @@ class FloorGraph:
|
|
|
:return:
|
|
|
"""
|
|
|
cons = list(c for c in self.connector_data if c.id == connector_id)
|
|
|
- return cons[0]
|
|
|
+ return cons[0] if len(cons)>0 else None
|
|
|
|
|
|
def get_element(self, element_id):
|
|
|
"""
|
|
@@ -711,6 +717,7 @@ def combine_systemgraph(floorgraphs):
|
|
|
open_vertical_pipes.extend(systemgraph.get_open_vertical_pipes())
|
|
|
# group systemvertex
|
|
|
projectgraph = ProjectGraph()
|
|
|
+ print(len(open_vertical_pipes))
|
|
|
for i in range(len(open_vertical_pipes)):
|
|
|
v1 = open_vertical_pipes[i]
|
|
|
group_pipes = [v1]
|
|
@@ -748,5 +755,5 @@ if '__main__'==__name__:
|
|
|
g.get_floor_graphs()
|
|
|
floorgraphs.append(g)
|
|
|
projectgraph= combine_systemgraph(floorgraphs)
|
|
|
- save_project_data(projectgraph, project_id)
|
|
|
+ #save_project_data(projectgraph, project_id)
|
|
|
# systemgraph_display.show_project(projectgraph)
|