mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
add fallback to the previous schema versions for docs and mappings
before it was breaking part of BlenderBIM UI if we would open IFC4X1 file
This commit is contained in:
@@ -98,11 +98,14 @@ def get_db(version):
|
||||
|
||||
with open(schema_path, "r") as fi:
|
||||
db[ifc_version][data_type] = json.load(fi)
|
||||
|
||||
version = ifcopenshell.util.schema.get_fallback_schema(version)
|
||||
return db.get(version)
|
||||
|
||||
|
||||
def get_schema_by_name(version):
|
||||
global schema_by_name
|
||||
version = ifcopenshell.util.schema.get_fallback_schema(version)
|
||||
if not schema_by_name[version]:
|
||||
schema_by_name[version] = ifcopenshell.ifcopenshell_wrapper.schema_by_name(version)
|
||||
return schema_by_name[version]
|
||||
|
||||
@@ -28,6 +28,16 @@ import ifcopenshell.util.attribute
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def get_fallback_schema(version):
|
||||
"""fallback to the schema version we do have docs and mapping for,
|
||||
needed to support IFC versions like 4X3_RC1, 4X1 etc"""
|
||||
if version.startswith("IFC4X3"):
|
||||
version = "IFC4X3"
|
||||
elif version.startswith("IFC4"):
|
||||
version = "IFC4"
|
||||
return version
|
||||
|
||||
|
||||
def is_a(entity, ifc_class):
|
||||
ifc_class = ifc_class.upper()
|
||||
if entity.name_uc() == ifc_class:
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
import ifcopenshell.util.schema
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -51,8 +52,10 @@ for schema in mapped_schemas:
|
||||
|
||||
|
||||
def get_applicable_types(ifc_class, schema="IFC4"):
|
||||
return entity_to_type_map[schema.upper()].get(ifc_class, [])
|
||||
schema = ifcopenshell.util.schema.get_fallback_schema(schema.upper())
|
||||
return entity_to_type_map[schema].get(ifc_class, [])
|
||||
|
||||
|
||||
def get_applicable_entities(ifc_type_class, schema="IFC4"):
|
||||
return type_to_entity_map[schema.upper()].get(ifc_type_class, [])
|
||||
schema = ifcopenshell.util.schema.get_fallback_schema(schema.upper())
|
||||
return type_to_entity_map[schema].get(ifc_type_class, [])
|
||||
|
||||
Reference in New Issue
Block a user