Use schema_identifier to get IFC4X3 schema more precisely

This commit is contained in:
Andrej730
2025-03-14 14:49:19 +05:00
parent 9f78d9881e
commit 2f87029434
11 changed files with 17 additions and 16 deletions
@@ -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
@@ -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()
@@ -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
@@ -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
@@ -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]
@@ -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]))
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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):
+1 -1
View File
@@ -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):
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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):