From ef98bd5120768e27bc5e05258d25b5c36fccf3bd Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 16 Jun 2023 13:28:31 +1000 Subject: [PATCH] Convert Ifc2Sql script to IfcPatch recipe and add geometry support --- src/blenderbim/scripts/ifc2sql.py | 281 -------------- src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py | 457 +++++++++++++++++++++++ 2 files changed, 457 insertions(+), 281 deletions(-) delete mode 100644 src/blenderbim/scripts/ifc2sql.py create mode 100644 src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py diff --git a/src/blenderbim/scripts/ifc2sql.py b/src/blenderbim/scripts/ifc2sql.py deleted file mode 100644 index 33ab7a5db0..0000000000 --- a/src/blenderbim/scripts/ifc2sql.py +++ /dev/null @@ -1,281 +0,0 @@ -import os -import json -import itertools -import ifcopenshell -import ifcopenshell.util.schema -import ifcopenshell.util.attribute - -import sqlite3 -import mysql.connector - - -class Ifc2Sql: - def execute(self): - self.sql_type = "sqlite" - # self.sql_type = "mysql" - - self.full_schema = False - self.is_strict = False - self.should_get_psets = True - self.should_expand = True - self.should_get_geometry_blob = True - self.should_skip_geometry_data = True - - filepath = "/home/dion/test2.ifc" - self.file = ifcopenshell.open(filepath) - self.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self.file.schema) - - if self.sql_type == "sqlite": - db_file = "/home/dion/test.db" - os.remove(db_file) - self.db = sqlite3.connect(db_file) - elif self.sql_type == "mysql": - self.db = mysql.connector.connect( - host="localhost", - user="root", - password="root", - database="test" - ) - - self.create_id_map() - if self.should_get_psets: - self.create_pset_table() - - if self.full_schema: - ifc_classes = [d.name() for d in self.schema.declarations() if str(d).startswith("", attribute): + if data_type not in ("list", "set", "select", "entity"): + return False + return True + return False