From c552e90897d57dfa9af856f2bf1b8edc9b255366 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 26 Aug 2020 20:08:28 +1000 Subject: [PATCH] Utility to extract documentation for all maintainable assets --- src/ifccobie/get_maintainable_assets.py | 43 +++++++ .../ifcopenshell/util/selector.py | 113 +++++++++--------- 2 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 src/ifccobie/get_maintainable_assets.py diff --git a/src/ifccobie/get_maintainable_assets.py b/src/ifccobie/get_maintainable_assets.py new file mode 100644 index 0000000000..68d2765974 --- /dev/null +++ b/src/ifccobie/get_maintainable_assets.py @@ -0,0 +1,43 @@ +import json +import ifcopenshell +import ifcopenshell.util.selector + +with open('../ifcblenderexport/blenderbim/bim/schema/entity_descriptions.json') as f: + entity_descriptions = json.load(f) +with open('../ifcblenderexport/blenderbim/bim/schema/enum_descriptions.json') as f: + enum_descriptions = json.load(f) + +print('{|class="wikitable"') +print('! IFC Class') +print('! Predefined Type') + +def print_entity(entity): + print('|-') + print('| ' + entity.name()) + print('| ') + if entity.name() in entity_descriptions: + print('{} ... [https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/HTML/link/{}.htm read more]'.format(entity_descriptions[entity.name()], entity.name().lower())) + else: + print('No description provided ... [https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/HTML/link/{}.htm read more]'.format(entity_descriptions[entity.name()], entity.name().lower())) + for attribute in entity.attributes(): + if attribute.name() == 'PredefinedType': + enum = attribute.type_of_attribute().declared_type() + print('\nThe following predefined types are defined:\n') + for item in enum.enumeration_items(): + #print('|-') + #print('| ' + entity.name()) + #print('| ' + item) + if enum.name() in enum_descriptions \ + and item in enum_descriptions[enum.name()]: + print('* \'\'\'{}\'\'\' - {} ... [https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/HTML/link/{}.htm read more]'.format(item, enum_descriptions[enum.name()][item], enum.name().lower())) + else: + print('* \'\'\'{}\'\'\' - No description provided ... [https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/HTML/link/{}.htm read more]'.format(item, enum.name().lower())) + + for subtype in entity.subtypes(): + print_entity(subtype) + +for asset in ifcopenshell.util.selector.cobie_component_assets: + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name('IFC4') + print_entity(schema.declaration_by_name(asset)) + +print('|}') diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 00ab727cf7..1867059f2c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -2,63 +2,64 @@ import ifcopenshell.util import ifcopenshell.util.element import lark +cobie_type_assets = [ + 'IfcDoorStyle', + 'IfcBuildingElementProxyType', + 'IfcChimneyType', + 'IfcCoveringType', + 'IfcDoorType', + 'IfcFootingType', + 'IfcPileType', + 'IfcRoofType', + 'IfcShadingDeviceType', + 'IfcWindowType', + 'IfcDistributionControlElementType', + 'IfcDistributionChamberElementType', + 'IfcEnergyConversionDeviceType', + 'IfcFlowControllerType', + 'IfcFlowMovingDeviceType', + 'IfcFlowStorageDeviceType', + 'IfcFlowTerminalType', + 'IfcFlowTreatmentDeviceType', + 'IfcElementAssemblyType', + 'IfcBuildingElementPartType', + 'IfcDiscreteAccessoryType', + 'IfcMechanicalFastenerType', + 'IfcReinforcingElementType', + 'IfcVibrationIsolatorType', + 'IfcFurnishingElementType', + 'IfcGeographicElementType', + 'IfcTransportElementType', + 'IfcSpatialZoneType', + 'IfcWindowStyle', +] +cobie_component_assets = [ + 'IfcBuildingElementProxy', + 'IfcChimney', + 'IfcCovering', + 'IfcDoor', + 'IfcShadingDevice', + 'IfcWindow', + 'IfcDistributionControlElement', + 'IfcDistributionChamberElement', + 'IfcEnergyConversionDevice', + 'IfcFlowController', + 'IfcFlowMovingDevice', + 'IfcFlowStorageDevice', + 'IfcFlowTerminal', + 'IfcFlowTreatmentDevice', + 'IfcDiscreteAccessory', + 'IfcTendon', + 'IfcTendonAnchor', + 'IfcVibrationIsolator', + 'IfcFurnishingElement', + 'IfcGeographicElement', + 'IfcTransportElement', +] + class Selector(): def parse(self, ifc_file, query): self.file = ifc_file - self.cobie_type_assets = [ - 'IfcDoorStyle', - 'IfcBuildingElementProxyType', - 'IfcChimneyType', - 'IfcCoveringType', - 'IfcDoorType', - 'IfcFootingType', - 'IfcPileType', - 'IfcRoofType', - 'IfcShadingDeviceType', - 'IfcWindowType', - 'IfcDistributionControlElementType', - 'IfcDistributionChamberElementType', - 'IfcEnergyConversionDeviceType', - 'IfcFlowControllerType', - 'IfcFlowMovingDeviceType', - 'IfcFlowStorageDeviceType', - 'IfcFlowTerminalType', - 'IfcFlowTreatmentDeviceType', - 'IfcElementAssemblyType', - 'IfcBuildingElementPartType', - 'IfcDiscreteAccessoryType', - 'IfcMechanicalFastenerType', - 'IfcReinforcingElementType', - 'IfcVibrationIsolatorType', - 'IfcFurnishingElementType', - 'IfcGeographicElementType', - 'IfcTransportElementType', - 'IfcSpatialZoneType', - 'IfcWindowStyle', - ] - self.cobie_component_assets = [ - 'IfcBuildingElementProxy', - 'IfcChimney', - 'IfcCovering', - 'IfcDoor', - 'IfcShadingDevice', - 'IfcWindow', - 'IfcDistributionControlElement', - 'IfcDistributionChamberElement', - 'IfcEnergyConversionDevice', - 'IfcFlowController', - 'IfcFlowMovingDevice', - 'IfcFlowStorageDevice', - 'IfcFlowTerminal', - 'IfcFlowTreatmentDevice', - 'IfcDiscreteAccessory', - 'IfcTendon', - 'IfcTendonAnchor', - 'IfcVibrationIsolator', - 'IfcFurnishingElement', - 'IfcGeographicElement', - 'IfcTransportElement', - ] l = lark.Lark('''start: query (lfunction query)* query: selector | group @@ -172,14 +173,14 @@ class Selector(): def get_class_selector(self, class_selector): if class_selector.children[0] == 'COBie': elements = [] - for ifc_class in self.cobie_component_assets: + for ifc_class in cobie_component_assets: try: elements += self.file.by_type(ifc_class) except: pass elif class_selector.children[0] == 'COBieType': elements = [] - for ifc_class in self.cobie_type_assets: + for ifc_class in cobie_type_assets: try: elements += self.file.by_type(ifc_class) except: