mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 09:48:41 +00:00
See #4838. Consistently use schema_identifiers throughout the code instead of schema to be more explicit.
This also means in the future we are better shaped to be a prototyping platform for future IFC versions.
This commit is contained in:
@@ -74,7 +74,7 @@ class IfcStore:
|
|||||||
last_transaction = ""
|
last_transaction = ""
|
||||||
history: list[TransactionStep] = []
|
history: list[TransactionStep] = []
|
||||||
future: list[TransactionStep] = []
|
future: list[TransactionStep] = []
|
||||||
schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3_ADD2"]
|
||||||
session_files: dict[str, ifcopenshell.file] = {}
|
session_files: dict[str, ifcopenshell.file] = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -94,7 +94,7 @@ class IfcStore:
|
|||||||
IfcStore.last_transaction = ""
|
IfcStore.last_transaction = ""
|
||||||
IfcStore.history = []
|
IfcStore.history = []
|
||||||
IfcStore.future = []
|
IfcStore.future = []
|
||||||
IfcStore.schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
IfcStore.schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3_ADD2"]
|
||||||
IfcStore.session_files = {}
|
IfcStore.session_files = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ProjectData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_export_schema(cls):
|
def get_export_schema(cls):
|
||||||
return [(s, s, "") for s in IfcStore.schema_identifiers]
|
return [(s, "IFC4X3" if s == "IFC4X3_ADD2" else s, "") for s in IfcStore.schema_identifiers]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def library_file(cls):
|
def library_file(cls):
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ class CreateProject(bpy.types.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
props = context.scene.BIMProjectProperties
|
props = context.scene.BIMProjectProperties
|
||||||
template = None if props.template_file == "0" else props.template_file
|
template = None if props.template_file == "0" else props.template_file
|
||||||
blenderbim.bim.schema.reload(props.export_schema)
|
|
||||||
if tool.Blender.is_default_scene():
|
if tool.Blender.is_default_scene():
|
||||||
for obj in bpy.data.objects:
|
for obj in bpy.data.objects:
|
||||||
bpy.data.objects.remove(obj)
|
bpy.data.objects.remove(obj)
|
||||||
@@ -125,6 +124,7 @@ class CreateProject(bpy.types.Operator):
|
|||||||
for mat in bpy.data.materials:
|
for mat in bpy.data.materials:
|
||||||
bpy.data.materials.remove(mat)
|
bpy.data.materials.remove(mat)
|
||||||
core.create_project(tool.Ifc, tool.Project, tool.Spatial, schema=props.export_schema, template=template)
|
core.create_project(tool.Ifc, tool.Project, tool.Spatial, schema=props.export_schema, template=template)
|
||||||
|
blenderbim.bim.schema.reload(tool.Ifc.get().schema_identifier)
|
||||||
tool.Blender.register_toolbar()
|
tool.Blender.register_toolbar()
|
||||||
|
|
||||||
def rollback(self, data):
|
def rollback(self, data):
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ cwd = os.path.dirname(os.path.realpath(__file__))
|
|||||||
|
|
||||||
|
|
||||||
class IfcSchema:
|
class IfcSchema:
|
||||||
def __init__(self, schema_name="IFC4"):
|
def __init__(self, schema_identifier="IFC4"):
|
||||||
schema_name = schema_name.upper()
|
if schema_identifier not in ("IFC2X3", "IFC4", "IFC4X3_ADD2"):
|
||||||
if schema_name not in ("IFC2X3", "IFC4", "IFC4X3"):
|
schema_identifier = "IFC4"
|
||||||
schema_name = "IFC4"
|
self.schema_identifier = schema_identifier
|
||||||
self.schema_name = schema_name
|
|
||||||
|
|
||||||
self.schema_dir = Path(cwd).joinpath("schema")
|
self.schema_dir = Path(cwd).joinpath("schema")
|
||||||
self.data_dir = Path(cwd).joinpath("data")
|
self.data_dir = Path(cwd).joinpath("data")
|
||||||
@@ -55,7 +54,7 @@ class IfcSchema:
|
|||||||
|
|
||||||
def load_pset_templates(self):
|
def load_pset_templates(self):
|
||||||
property_paths = self.data_dir.joinpath("pset").glob("*.ifc")
|
property_paths = self.data_dir.joinpath("pset").glob("*.ifc")
|
||||||
self.psetqto = ifcopenshell.util.pset.get_template(self.schema_name)
|
self.psetqto = ifcopenshell.util.pset.get_template(self.schema_identifier)
|
||||||
# Keep only the first template, which is the official buildingSMART one
|
# Keep only the first template, which is the official buildingSMART one
|
||||||
self.psetqto.templates = self.psetqto.templates[0:1]
|
self.psetqto.templates = self.psetqto.templates[0:1]
|
||||||
self.psetqto.get_applicable.cache_clear()
|
self.psetqto.get_applicable.cache_clear()
|
||||||
@@ -96,6 +95,6 @@ class IfcSchema:
|
|||||||
ifc = IfcSchema()
|
ifc = IfcSchema()
|
||||||
|
|
||||||
|
|
||||||
def reload(schema_name):
|
def reload(schema_identifier):
|
||||||
global ifc
|
global ifc
|
||||||
ifc = IfcSchema(schema_name)
|
ifc = IfcSchema(schema_identifier)
|
||||||
|
|||||||
@@ -40,19 +40,19 @@ class PsetQto:
|
|||||||
templates_path = {
|
templates_path = {
|
||||||
"IFC2X3": "Pset_IFC2X3.ifc",
|
"IFC2X3": "Pset_IFC2X3.ifc",
|
||||||
"IFC4": "Pset_IFC4_ADD2.ifc",
|
"IFC4": "Pset_IFC4_ADD2.ifc",
|
||||||
"IFC4X3": "Pset_IFC4X3.ifc"
|
"IFC4X3_ADD2": "Pset_IFC4X3.ifc"
|
||||||
}
|
}
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
def __init__(self, schema: str, templates=None) -> None:
|
def __init__(self, schema_identifier: str, templates=None) -> None:
|
||||||
self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema)
|
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]))
|
path = str(folder_path.joinpath("schema", self.templates_path[schema_identifier]))
|
||||||
templates = [ifcopenshell.open(path)]
|
templates = [ifcopenshell.open(path)]
|
||||||
# See bug 3583. We backport this change from IFC4X3 because it just makes sense.
|
# See bug 3583. We backport this change from IFC4X3 because it just makes sense.
|
||||||
# Users aren't forced to use it.
|
# Users aren't forced to use it.
|
||||||
if schema == "IFC4":
|
if schema_identifier == "IFC4":
|
||||||
for element in templates[0].by_type("IfcPropertySetTemplate"):
|
for element in templates[0].by_type("IfcPropertySetTemplate"):
|
||||||
if element.TemplateType == "QTO_OCCURRENCEDRIVEN":
|
if element.TemplateType == "QTO_OCCURRENCEDRIVEN":
|
||||||
element.TemplateType = "QTO_TYPEDRIVENOVERRIDE"
|
element.TemplateType = "QTO_TYPEDRIVENOVERRIDE"
|
||||||
|
|||||||
Reference in New Issue
Block a user