diff --git a/src/bonsai/bonsai/bim/module/pset_template/data.py b/src/bonsai/bonsai/bim/module/pset_template/data.py index ccf589b463..8eae1fdc42 100644 --- a/src/bonsai/bonsai/bim/module/pset_template/data.py +++ b/src/bonsai/bonsai/bim/module/pset_template/data.py @@ -56,7 +56,7 @@ class PsetTemplatesData: ifc_file = IfcStore.pset_template_file if not ifc_file: return [] - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema) + schema = ifcopenshell.schema_by_name(ifc_file.schema) version = ifc_file.schema enum_items = [ (t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", "")) @@ -97,7 +97,7 @@ class PsetTemplatesData: # If mixed typed are used (e.g. during transition), assume type is not specified. pset_type = next(iter(pset_types)) if len(pset_types) == 1 else None - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema) + schema = ifcopenshell.schema_by_name(ifc_file.schema) attribute = schema.declaration_by_name("IfcSimplePropertyTemplate").attributes()[0] enum_items = [ a diff --git a/src/bonsai/scripts/generate_util_type_json.py b/src/bonsai/scripts/generate_util_type_json.py index f48b35dcbf..c162800f54 100644 --- a/src/bonsai/scripts/generate_util_type_json.py +++ b/src/bonsai/scripts/generate_util_type_json.py @@ -24,7 +24,7 @@ import ifcopenshell.util.schema def generate_ifc4_entity_map(filepath, schema_name, manual_corrections={}): filepath = filepath - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name) + schema = ifcopenshell.schema_by_name(schema_name) entity_to_type_map = {} @@ -154,7 +154,7 @@ ifc4x3_corrections = { "IfcDistributionElement": ["IfcDistributionElementType"], "IfcBuiltElement": ["IfcBuiltElementType"], } -entity_to_type_map4x3 = generate_ifc4_entity_map("IFC4X3_TC1.exp", "ifc4x3", ifc4x3_corrections) +entity_to_type_map4x3 = generate_ifc4_entity_map("IFC4X3_TC1.exp", "IFC4X3", ifc4x3_corrections) # some manual IFC4 corrections (more details in entity_to_type_map_4.json commits history) ifc4_corrections = { @@ -165,6 +165,6 @@ ifc4_corrections = { "IfcDistributionElement": ["IfcDistributionElementType"], } # -entity_to_type_map4 = generate_ifc4_entity_map("IFC4.exp", "ifc4", ifc4_corrections) +entity_to_type_map4 = generate_ifc4_entity_map("IFC4.exp", "IFC4", ifc4_corrections) entity_to_type_map2x3 = generate_ifc2x3_entity_map() diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index ee5ed67f48..260b3e5f41 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -237,6 +237,10 @@ def schema_by_name( :param schema: Which IFC schema to use, chosen from "IFC2X3", "IFC4", or "IFC4X3". These refer to the ISO approved versions of IFC. + E.g. from ``ifcopenshell.file.schema_identifier``. + Passing ``ifcopenshell.file.schema`` also will work but may result + in not precisely matching schema but it's only conern if you're + using not one of the main schemas. :param schema_version: If you want to specify an exact version of IFC that may not be an ISO approved version, use this argument instead of ``schema``. IFC versions on technical.buildingsmart.org are diff --git a/src/ifcopenshell-python/ifcopenshell/util/cost.py b/src/ifcopenshell-python/ifcopenshell/util/cost.py index 5d9189b337..9c434d6ce3 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/cost.py +++ b/src/ifcopenshell-python/ifcopenshell/util/cost.py @@ -281,7 +281,7 @@ def get_cost_values(cost_item: ifcopenshell.entity_instance) -> list[dict[str, s def get_cost_schedule_types(file: ifcopenshell.file) -> list[dict[str, str]]: - schema: ifcopenshell_wrapper.schema_definition = ifcopenshell_wrapper.schema_by_name(file.schema) + schema: ifcopenshell_wrapper.schema_definition = ifcopenshell_wrapper.schema_by_name(file.schema_identifier) results = [] declaration = schema.declaration_by_name("IfcCostSchedule") version = file.schema_identifier diff --git a/src/ifcopenshell-python/ifcopenshell/util/doc.py b/src/ifcopenshell-python/ifcopenshell/util/doc.py index b444966068..0a2dad205b 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/doc.py +++ b/src/ifcopenshell-python/ifcopenshell/util/doc.py @@ -113,8 +113,7 @@ def get_schema_by_name(version: str) -> ifcopenshell_wrapper.schema_definition: global schema_by_name version = ifcopenshell.util.schema.get_fallback_schema(version) if not schema_by_name[version]: - schema_name = "IFC4X3_ADD2" if version == "IFC4X3" else version - schema_by_name[version] = ifcopenshell_wrapper.schema_by_name(schema_name) + schema_by_name[version] = ifcopenshell.schema_by_name(version) return schema_by_name[version] diff --git a/src/ifcopenshell-python/ifcopenshell/util/pset.py b/src/ifcopenshell-python/ifcopenshell/util/pset.py index bf90570251..025f9f042c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/pset.py +++ b/src/ifcopenshell-python/ifcopenshell/util/pset.py @@ -46,9 +46,7 @@ class PsetQto: # fmt: on def __init__(self, schema_identifier: str, templates=None) -> None: - if schema_identifier == "IFC4X3": - schema_identifier = "IFC4X3_ADD2" - self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_identifier) + self.schema = ifcopenshell.schema_by_name(schema_identifier) if not templates: folder_path = pathlib.Path(__file__).parent.absolute() path = str(folder_path.joinpath("schema", self.templates_path[schema_identifier])) diff --git a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py index 90ac909e3e..d4ef3feba9 100644 --- a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py +++ b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py @@ -140,7 +140,7 @@ class Patcher: # Assume it's a filepath - existing or not. pass - self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self.file.schema) + self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self.file.schema_identifier) if self.sql_type == "sqlite": self.db = sqlite3.connect(database) diff --git a/src/ifcsverchok/nodes/ifc/by_type.py b/src/ifcsverchok/nodes/ifc/by_type.py index 96c9d84942..c4c6f9bdb7 100644 --- a/src/ifcsverchok/nodes/ifc/by_type.py +++ b/src/ifcsverchok/nodes/ifc/by_type.py @@ -68,7 +68,7 @@ def get_ifc_classes(self, context): file = SvIfcStore.get_file() if not file: return [] - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema) + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema_identifier) declaration = schema.declaration_by_name(self.ifc_product) def get_classes(declaration): diff --git a/src/ifcsverchok/nodes/ifc/pick_ifc_class.py b/src/ifcsverchok/nodes/ifc/pick_ifc_class.py index 5cf24b9602..3cbbf03af0 100644 --- a/src/ifcsverchok/nodes/ifc/pick_ifc_class.py +++ b/src/ifcsverchok/nodes/ifc/pick_ifc_class.py @@ -64,7 +64,7 @@ def get_ifc_classes(self, context): file = SvIfcStore.get_file() if not file: return [] - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema) + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(file.schema_identifier) declaration = schema.declaration_by_name(self.ifc_product) def get_classes(declaration): diff --git a/src/ifcsverchok/nodes/ifc/read_entity.py b/src/ifcsverchok/nodes/ifc/read_entity.py index fb581d1b63..9ea2fa3490 100644 --- a/src/ifcsverchok/nodes/ifc/read_entity.py +++ b/src/ifcsverchok/nodes/ifc/read_entity.py @@ -58,7 +58,7 @@ class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.S ifc_class = entity.is_a() file = SvIfcStore.get_file() if file: - schema_name = file.wrapped_data.schema + schema_name = file.schema_identifier else: schema_name = "IFC4" self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 44b2bedfe9..7ea972087f 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -257,7 +257,7 @@ class Attribute(Facet): return super().filter(ifc_file, elements) results = [] - schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema) + schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema_identifier) entities = {entity.name(): entity for entity in schema.entities()} def ignore_subtypes(entity):