Support for importing IFCZIP files. See #834

This commit is contained in:
Dion Moult
2020-04-12 09:17:26 +10:00
parent 42fedf81c4
commit bdfe197c64
2 changed files with 14 additions and 3 deletions
@@ -7,6 +7,9 @@ import time
import mathutils
import math
import multiprocessing
import zipfile
import tempfile
from pathlib import Path
from .helper import SIUnitHelper
from . import schema
from . import ifc
@@ -589,7 +592,16 @@ class IfcImporter():
def load_file(self):
self.ifc_import_settings.logger.info('loading file {}'.format(self.ifc_import_settings.input_file))
self.file = ifcopenshell.open(self.ifc_import_settings.input_file)
extension = self.ifc_import_settings.input_file.split('.')[-1]
if extension == '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 == 'ifc':
self.file = ifcopenshell.open(self.ifc_import_settings.input_file)
ifc.IfcStore.file = self.file
def set_ifc_file(self):
@@ -64,9 +64,8 @@ class ExportIFC(bpy.types.Operator):
class ImportIFC(bpy.types.Operator, ImportHelper):
bl_idname = "import.ifc"
bl_label = "Import .ifc file"
filename_ext = ".ifc"
filter_glob: bpy.props.StringProperty(default="*.ifc", options={'HIDDEN'})
filter_glob: bpy.props.StringProperty(default="*.ifc;*.ifczip", options={'HIDDEN'})
def execute(self, context):
start = time.time()