IFC4X3/IFC2X3 pset templates library

Generated from xmls from the ISO release of IFC4X3.
Based on https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/annex/annex-a/general-usage/IFC4_ADD2.ifc

Also generated pset templates library for IFC2X3 (also based on similar xmls) but IFC2X3 ifc pset library is using... IFC4X3 schema because IfcPropertySetTemplate and IfcRelDeclares are not available in IFC2X3. Which is okay for our purposes for now.

Will need to update IFC4X3 library if one of the issues will be resolved:
https://github.com/buildingSMART/IFC4.3.x-development/issues/587
https://github.com/buildingSMART/IFC4.3.x-development/issues/586
This commit is contained in:
Andrej730
2023-02-21 11:50:09 +05:00
parent 2fe2c349fd
commit 708dc6aca2
8 changed files with 8696 additions and 11 deletions
@@ -26,6 +26,7 @@ import ifcopenshell.api
import ifcopenshell.util.selector
import ifcopenshell.util.representation
import blenderbim.bim.handler
import blenderbim.bim.schema
import blenderbim.tool as tool
import blenderbim.core.project as core
import blenderbim.core.context
@@ -54,6 +55,7 @@ class CreateProject(bpy.types.Operator):
def _execute(self, context):
props = context.scene.BIMProjectProperties
template = None if props.template_file == "0" else props.template_file
blenderbim.bim.schema.reload(props.export_schema)
core.create_project(tool.Ifc, tool.Project, schema=props.export_schema, template=template)
def rollback(self, data):
@@ -561,6 +563,7 @@ class LoadProjectElements(bpy.types.Operator):
def execute(self, context):
self.props = context.scene.BIMProjectProperties
self.file = IfcStore.get_file()
blenderbim.bim.schema.reload(self.file.schema)
start = time.time()
logger = logging.getLogger("ImportIFC")
path_log = os.path.join(context.scene.BIMProperties.data_dir, "process.log")
@@ -22,6 +22,7 @@ import ifcopenshell
import ifcopenshell.api
import blenderbim.bim.schema
import blenderbim.bim.handler
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
@@ -223,7 +224,7 @@ class SavePsetTemplateFile(bpy.types.Operator):
def execute(self, context):
IfcStore.pset_template_file.write(IfcStore.pset_template_path)
blenderbim.bim.handler.purge_module_data()
blenderbim.bim.schema.reload()
blenderbim.bim.schema.reload(tool.Ifc.get().schema)
return {"FINISHED"}
+10 -5
View File
@@ -27,7 +27,12 @@ cwd = os.path.dirname(os.path.realpath(__file__))
class IfcSchema:
def __init__(self):
def __init__(self, schema_name="IFC4"):
schema_name = schema_name.upper()
if schema_name not in ("IFC2X3", "IFC4", "IFC4X3"):
schema_name = "IFC4"
self.schema_name = schema_name
self.schema_dir = Path(cwd).joinpath("schema")
self.data_dir = Path(cwd).joinpath("data")
# TODO: Make it less troublesome
@@ -51,8 +56,7 @@ class IfcSchema:
def load_pset_templates(self):
property_paths = self.data_dir.joinpath("pset").glob("*.ifc")
# TODO: add IFC2X3 PsetQto template support
self.psetqto = ifcopenshell.util.pset.get_template("IFC4")
self.psetqto = ifcopenshell.util.pset.get_template(self.schema_name)
# Keep only the first template, which is the official buildingSMART one
self.psetqto.templates = self.psetqto.templates[0:1]
self.psetqto.get_applicable.cache_clear()
@@ -62,6 +66,7 @@ class IfcSchema:
self.psetqto.templates.append(ifcopenshell.open(path))
def load(self):
# TODO: need to update for ifc4x3?
for product in self.products:
with open(os.path.join(self.schema_dir, f"{product}_IFC4.json")) as f:
setattr(self, product, json.load(f))
@@ -99,6 +104,6 @@ class IfcSchema:
ifc = IfcSchema()
def reload():
def reload(schema_name):
global ifc
ifc = IfcSchema()
ifc = IfcSchema(schema_name)