mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Use schema_identifier to get IFC4X3 schema more precisely
This commit is contained in:
@@ -56,7 +56,7 @@ class PsetTemplatesData:
|
|||||||
ifc_file = IfcStore.pset_template_file
|
ifc_file = IfcStore.pset_template_file
|
||||||
if not ifc_file:
|
if not ifc_file:
|
||||||
return []
|
return []
|
||||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema)
|
schema = ifcopenshell.schema_by_name(ifc_file.schema)
|
||||||
version = ifc_file.schema
|
version = ifc_file.schema
|
||||||
enum_items = [
|
enum_items = [
|
||||||
(t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", ""))
|
(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.
|
# 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
|
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]
|
attribute = schema.declaration_by_name("IfcSimplePropertyTemplate").attributes()[0]
|
||||||
enum_items = [
|
enum_items = [
|
||||||
a
|
a
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import ifcopenshell.util.schema
|
|||||||
|
|
||||||
def generate_ifc4_entity_map(filepath, schema_name, manual_corrections={}):
|
def generate_ifc4_entity_map(filepath, schema_name, manual_corrections={}):
|
||||||
filepath = filepath
|
filepath = filepath
|
||||||
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
|
schema = ifcopenshell.schema_by_name(schema_name)
|
||||||
|
|
||||||
entity_to_type_map = {}
|
entity_to_type_map = {}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ ifc4x3_corrections = {
|
|||||||
"IfcDistributionElement": ["IfcDistributionElementType"],
|
"IfcDistributionElement": ["IfcDistributionElementType"],
|
||||||
"IfcBuiltElement": ["IfcBuiltElementType"],
|
"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)
|
# some manual IFC4 corrections (more details in entity_to_type_map_4.json commits history)
|
||||||
ifc4_corrections = {
|
ifc4_corrections = {
|
||||||
@@ -165,6 +165,6 @@ ifc4_corrections = {
|
|||||||
"IfcDistributionElement": ["IfcDistributionElementType"],
|
"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()
|
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",
|
:param schema: Which IFC schema to use, chosen from "IFC2X3", "IFC4",
|
||||||
or "IFC4X3". These refer to the ISO approved versions of IFC.
|
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
|
: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
|
that may not be an ISO approved version, use this argument instead
|
||||||
of ``schema``. IFC versions on technical.buildingsmart.org are
|
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]]:
|
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 = []
|
results = []
|
||||||
declaration = schema.declaration_by_name("IfcCostSchedule")
|
declaration = schema.declaration_by_name("IfcCostSchedule")
|
||||||
version = file.schema_identifier
|
version = file.schema_identifier
|
||||||
|
|||||||
@@ -113,8 +113,7 @@ def get_schema_by_name(version: str) -> ifcopenshell_wrapper.schema_definition:
|
|||||||
global schema_by_name
|
global schema_by_name
|
||||||
version = ifcopenshell.util.schema.get_fallback_schema(version)
|
version = ifcopenshell.util.schema.get_fallback_schema(version)
|
||||||
if not schema_by_name[version]:
|
if not schema_by_name[version]:
|
||||||
schema_name = "IFC4X3_ADD2" if version == "IFC4X3" else version
|
schema_by_name[version] = ifcopenshell.schema_by_name(version)
|
||||||
schema_by_name[version] = ifcopenshell_wrapper.schema_by_name(schema_name)
|
|
||||||
return schema_by_name[version]
|
return schema_by_name[version]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ class PsetQto:
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
def __init__(self, schema_identifier: str, templates=None) -> None:
|
def __init__(self, schema_identifier: str, templates=None) -> None:
|
||||||
if schema_identifier == "IFC4X3":
|
self.schema = ifcopenshell.schema_by_name(schema_identifier)
|
||||||
schema_identifier = "IFC4X3_ADD2"
|
|
||||||
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_identifier)
|
|
||||||
if not templates:
|
if not templates:
|
||||||
folder_path = pathlib.Path(__file__).parent.absolute()
|
folder_path = pathlib.Path(__file__).parent.absolute()
|
||||||
path = str(folder_path.joinpath("schema", self.templates_path[schema_identifier]))
|
path = str(folder_path.joinpath("schema", self.templates_path[schema_identifier]))
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class Patcher:
|
|||||||
# Assume it's a filepath - existing or not.
|
# Assume it's a filepath - existing or not.
|
||||||
pass
|
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":
|
if self.sql_type == "sqlite":
|
||||||
self.db = sqlite3.connect(database)
|
self.db = sqlite3.connect(database)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def get_ifc_classes(self, context):
|
|||||||
file = SvIfcStore.get_file()
|
file = SvIfcStore.get_file()
|
||||||
if not file:
|
if not file:
|
||||||
return []
|
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)
|
declaration = schema.declaration_by_name(self.ifc_product)
|
||||||
|
|
||||||
def get_classes(declaration):
|
def get_classes(declaration):
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def get_ifc_classes(self, context):
|
|||||||
file = SvIfcStore.get_file()
|
file = SvIfcStore.get_file()
|
||||||
if not file:
|
if not file:
|
||||||
return []
|
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)
|
declaration = schema.declaration_by_name(self.ifc_product)
|
||||||
|
|
||||||
def get_classes(declaration):
|
def get_classes(declaration):
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class SvIfcReadEntity(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helper.S
|
|||||||
ifc_class = entity.is_a()
|
ifc_class = entity.is_a()
|
||||||
file = SvIfcStore.get_file()
|
file = SvIfcStore.get_file()
|
||||||
if file:
|
if file:
|
||||||
schema_name = file.wrapped_data.schema
|
schema_name = file.schema_identifier
|
||||||
else:
|
else:
|
||||||
schema_name = "IFC4"
|
schema_name = "IFC4"
|
||||||
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
|
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class Attribute(Facet):
|
|||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
|
|
||||||
results = []
|
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()}
|
entities = {entity.name(): entity for entity in schema.entities()}
|
||||||
|
|
||||||
def ignore_subtypes(entity):
|
def ignore_subtypes(entity):
|
||||||
|
|||||||
Reference in New Issue
Block a user