"""PipeNetwork Data . """ import test from systemrelation import systemutils def get_dicdata(sql,dic): data=test.get_data(sql) dic_data=[dict(zip(dic,item)) for item in data] return list(dic_data) def get_element_data(model_id): """ Cache all Element from Db :return: """ element_data=[] component_sql="select * from revit.component where model_id='%s'"%(model_id) COMPONENT_KEYS = [ 'id', 'model_id', 'local_id', 'local_name', 'family', 'location', 'outline', 'source_id', 'name', 'revit_id', 'parameters', 'type', 'tag', 'owner', 'last_update', 'create_time', 'owner_id', 'family_name', 'owner_source_id' ] element_data.extend(get_dicdata(component_sql,COMPONENT_KEYS)) equipment_sql="select * from revit.equipment where model_id='%s'"%(model_id) EQUIPMENT_KEYS = [ 'id', 'model_id', 'local_id', 'local_name', 'family', 'location', 'outline', 'last_update', 'create_time', 'source_id', 'name', 'parameters', 'revit_id', 'type', 'tag', 'family_name', ] element_data.extend(get_dicdata(equipment_sql,EQUIPMENT_KEYS)) other_sql="select * from revit.other where model_id='%s'"%(model_id) OTHER_KEYS = [ 'id', 'model_id', 'connected_ids', 'source_id', 'name', 'revit_id', 'type', 'create_time', 'last_update', 'location', 'outline' ] element_data.extend(get_dicdata(other_sql,OTHER_KEYS)) pipe_sql = "select * from revit.pipe where model_id='%s'" % (model_id) PIPE_KEYS = [ 'id', 'model_id', 'location', 'outline', 'connected_ids', 'mep_system_type', 'diameter', 'source_id', 'name', 'revit_id', 'type', 'last_update', 'create_time', 'parameters' ] element_data.extend(get_dicdata(pipe_sql, PIPE_KEYS)) duct_sql="select * from revit.duct where model_id='%s'"%(model_id) DUCT_KEYS = [ 'id', 'model_id', 'location', 'outline', 'connected_ids', 'mep_system_type', 'shape', 'diameter', 'width', 'height', 'source_id', 'revit_id', 'name', 'type', 'last_update', 'create_time', 'parameters' ] element_data.extend(get_dicdata(duct_sql,DUCT_KEYS)) element_data=list(map(systemutils.dic2obj, element_data)) return element_data 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', 'belong', 'belong_type', 'origin', 'domain', 'description', 'connected', 'owner', 'connected_ids', 'mep_system_type', 'source_id', 'revit_id', 'type', 'create_time', 'last_update', 'connect_id_json' ] connector_data.extend(get_dicdata(connector_sql, CONNECTOR_KEYS)) connector_data=list(map(systemutils.dic2obj,connector_data)) return connector_data if '__main__'==__name__: model_id="cf4e11a0e25811e999b6dbc4c75fa946" system_name="喷淋管" domain="DomainPiping" g=get_connectors_data(model_id,system_name,domain) print (g)