diff --git a/src/ifcfm/ifcfm/parser.py b/src/ifcfm/ifcfm/parser.py index 69a27815dc..fc369e5003 100644 --- a/src/ifcfm/ifcfm/parser.py +++ b/src/ifcfm/ifcfm/parser.py @@ -1,4 +1,3 @@ - # IfcFM - IFC for facility management # Copyright (C) 2021 Dion Moult # @@ -277,7 +276,7 @@ class Parser: # Hack category = None if ifc_file == "arch": - #if "Data" in psets and "COBie.Type.Category" in psets["Data"]: + # if "Data" in psets and "COBie.Type.Category" in psets["Data"]: # if ":" in psets["Data"]["COBie.Type.Category"]: # category = psets["Data"]["COBie.Type.Category"].replace(" : ", ":") if "Data" in psets and "Classification.Uniclass.Pr.Number" in psets["Data"]: @@ -332,7 +331,7 @@ class Parser: else: space = element.ContainedInStructure[0].RelatingStructure if space.is_a("IfcSpace"): - space_name = space.Name + space_name = space.Name self.components[name] = { "Name": name, diff --git a/src/ifcfm/ifcfm/util.py b/src/ifcfm/ifcfm/util.py new file mode 100644 index 0000000000..ce67e6adc2 --- /dev/null +++ b/src/ifcfm/ifcfm/util.py @@ -0,0 +1,51 @@ +# IfcFM - IFC for facility management +# Copyright (C) 2021 Dion Moult +# +# This file is part of IfcFM. +# +# IfcFM is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# IfcFM is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with IfcFM. If not, see . + + +import textwrap +import ifcopenshell +import ifcopenshell.util.fm +import ifcopenshell.util.attribute + + +def print_element(declaration, levels=0): + if declaration.name() == "IfcCooledBeamType": + return + if declaration.is_abstract(): + print("{}{} (abstract)".format("\t\t" * levels, declaration.name())) + else: + types = [] + for attribute in declaration.all_attributes(): + if attribute.name() == "PredefinedType": + types = ifcopenshell.util.attribute.get_enum_items(attribute) + print("{}{}".format("\t\t" * levels, declaration.name())) + if types: + for line in textwrap.wrap(", ".join(types), width=60): + print("{}{}".format("\t\t" * (levels + 1), line)) + for subtype in declaration.subtypes(): + print_element(subtype, levels=levels + 1) + + +def print_fmhem_documentation(schema="IFC4"): + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema) + for ifc_class in ifcopenshell.util.fm.fmhem_classes: + try: + declaration = schema.declaration_by_name(ifc_class) + print_element(declaration) + except: + pass