mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
IfcZip and IfcXML can now be set manually, and prevent double loading when importing, which can save ~20 seconds for large file imports.
This commit is contained in:
@@ -153,8 +153,7 @@ def purge_module_data():
|
|||||||
def loadIfcStore(scene):
|
def loadIfcStore(scene):
|
||||||
IfcStore.purge()
|
IfcStore.purge()
|
||||||
purge_module_data()
|
purge_module_data()
|
||||||
ifc_file = IfcStore.get_file()
|
if not IfcStore.get_file():
|
||||||
if not ifc_file:
|
|
||||||
return
|
return
|
||||||
IfcStore.get_schema()
|
IfcStore.get_schema()
|
||||||
IfcStore.reload_linked_elements()
|
IfcStore.reload_linked_elements()
|
||||||
|
|||||||
@@ -60,11 +60,26 @@ class IfcStore:
|
|||||||
IfcStore.path = bpy.context.scene.BIMProperties.ifc_file
|
IfcStore.path = bpy.context.scene.BIMProperties.ifc_file
|
||||||
if IfcStore.path:
|
if IfcStore.path:
|
||||||
try:
|
try:
|
||||||
IfcStore.file = ifcopenshell.open(IfcStore.path)
|
IfcStore.load_file(IfcStore.path)
|
||||||
except:
|
except:
|
||||||
IfcStore.file
|
pass
|
||||||
return IfcStore.file
|
return IfcStore.file
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def load_file(path):
|
||||||
|
extension = path.split(".")[-1]
|
||||||
|
if extension.lower() == "ifczip":
|
||||||
|
with tempfile.TemporaryDirectory() as unzipped_path:
|
||||||
|
with zipfile.ZipFile(path, "r") as zip_ref:
|
||||||
|
zip_ref.extractall(unzipped_path)
|
||||||
|
for filename in Path(unzipped_path).glob("**/*.ifc"):
|
||||||
|
IfcStore.file = ifcopenshell.open(filename)
|
||||||
|
return
|
||||||
|
elif extension.lower() == "ifcxml":
|
||||||
|
IfcStore.file = ifcopenshell.file(ifcopenshell.ifcopenshell_wrapper.parse_ifcxml(path))
|
||||||
|
elif extension.lower() == "ifc":
|
||||||
|
IfcStore.file = ifcopenshell.open(path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_schema():
|
def get_schema():
|
||||||
if IfcStore.file is None:
|
if IfcStore.file is None:
|
||||||
|
|||||||
@@ -214,8 +214,6 @@ class IfcImporter:
|
|||||||
self.profile_code("Purge diffs")
|
self.profile_code("Purge diffs")
|
||||||
self.load_file()
|
self.load_file()
|
||||||
self.profile_code("Loading file")
|
self.profile_code("Loading file")
|
||||||
self.set_ifc_file()
|
|
||||||
self.profile_code("Setting file")
|
|
||||||
self.calculate_unit_scale()
|
self.calculate_unit_scale()
|
||||||
self.profile_code("Calculate unit scale")
|
self.profile_code("Calculate unit scale")
|
||||||
self.calculate_model_offset()
|
self.calculate_model_offset()
|
||||||
@@ -973,25 +971,8 @@ class IfcImporter:
|
|||||||
|
|
||||||
def load_file(self):
|
def load_file(self):
|
||||||
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
self.ifc_import_settings.logger.info("loading file %s", self.ifc_import_settings.input_file)
|
||||||
extension = self.ifc_import_settings.input_file.split(".")[-1]
|
|
||||||
if extension.lower() == "ifczip":
|
|
||||||
with tempfile.TemporaryDirectory() as unzipped_path:
|
|
||||||
with zipfile.ZipFile(self.ifc_import_settings.input_file, "r") as zip_ref:
|
|
||||||
zip_ref.extractall(unzipped_path)
|
|
||||||
for filename in Path(unzipped_path).glob("**/*.ifc"):
|
|
||||||
self.file = ifcopenshell.open(filename)
|
|
||||||
break
|
|
||||||
elif extension.lower() == "ifcxml":
|
|
||||||
self.file = ifcopenshell.file(
|
|
||||||
ifcopenshell.ifcopenshell_wrapper.parse_ifcxml(self.ifc_import_settings.input_file)
|
|
||||||
)
|
|
||||||
elif extension.lower() == "ifc":
|
|
||||||
self.file = ifcopenshell.open(self.ifc_import_settings.input_file)
|
|
||||||
IfcStore.file = self.file
|
|
||||||
|
|
||||||
def set_ifc_file(self):
|
|
||||||
bpy.context.scene.BIMProperties.ifc_file = self.ifc_import_settings.input_file
|
bpy.context.scene.BIMProperties.ifc_file = self.ifc_import_settings.input_file
|
||||||
IfcStore.path = self.ifc_import_settings.input_file
|
self.file = IfcStore.get_file()
|
||||||
|
|
||||||
def calculate_unit_scale(self):
|
def calculate_unit_scale(self):
|
||||||
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
|
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(self.file)
|
||||||
|
|||||||
Reference in New Issue
Block a user