From f6c2a18e63e6ed460ba8f1b80341a9ed64dfb59f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 3 Feb 2021 16:22:23 +1100 Subject: [PATCH] Now, users don't need to consider include curves and 2D annotations will always be imported. See #1142. --- .../blenderbim/bim/import_ifc.py | 35 +++++++++++++++++-- .../blenderbim/bim/operator.py | 2 -- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index fe78871a11..73a7136e0e 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -280,8 +280,6 @@ class IfcImporter: self.settings = ifcopenshell.geom.settings() self.settings.set_deflection_tolerance(self.ifc_import_settings.deflection_tolerance) self.settings.set_angular_tolerance(self.ifc_import_settings.angular_tolerance) - if self.ifc_import_settings.should_import_curves: - self.settings.set(self.settings.INCLUDE_CURVES, True) self.settings_native = ifcopenshell.geom.settings() self.settings_native.set(self.settings_native.INCLUDE_CURVES, True) self.settings_2d = ifcopenshell.geom.settings() @@ -355,6 +353,8 @@ class IfcImporter: # self.profile_code("Creating native products") self.create_products() self.profile_code("Creating meshified products") + self.create_annotation() + self.profile_code("Creating annotation") self.place_objects_in_spatial_tree() self.profile_code("Placing objects in spatial tree") if self.ifc_import_settings.should_merge_by_class: @@ -718,6 +718,36 @@ class IfcImporter: break print("Done creating geometry") + def create_annotation(self): + if self.ifc_import_settings.should_use_cpu_multiprocessing: + iterator = ifcopenshell.geom.iterator( + self.settings_2d, + self.file, + multiprocessing.cpu_count(), + include=self.file.by_type("IfcAnnotation") + ) + else: + iterator = ifcopenshell.geom.iterator( + self.settings_2d, self.file, include=self.file.by_type("IfcAnnotation") + ) + valid_file = iterator.initialize() + if not valid_file: + return False + checkpoint = time.time() + total = 0 + while True: + total += 1 + if total % 250 == 0: + print("{} elements processed in {:.2f}s ...".format(total, time.time() - checkpoint)) + checkpoint = time.time() + shape = iterator.get() + if shape: + self.create_product(self.file.by_id(shape.guid), shape) + if not iterator.next(): + break + print("Done creating geometry") + + def create_product(self, element, shape=None): if element is None: return @@ -1537,7 +1567,6 @@ class IfcImportSettings: self.input_file = None self.diff_file = None self.should_import_type_representations = False - self.should_import_curves = False self.should_import_spaces = False self.should_auto_set_workarounds = True self.should_use_cpu_multiprocessing = True diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 6f30063977..556e176c05 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -112,7 +112,6 @@ class ImportIFC(bpy.types.Operator, ImportHelper): filter_glob: bpy.props.StringProperty(default="*.ifc;*.ifczip;*.ifcxml", options={"HIDDEN"}) should_import_type_representations: bpy.props.BoolProperty(name="Import Type Representations", default=False) - should_import_curves: bpy.props.BoolProperty(name="Import Curves", default=False) should_import_spaces: bpy.props.BoolProperty(name="Import Spaces", default=False) should_auto_set_workarounds: bpy.props.BoolProperty(name="Automatically Set Vendor Workarounds", default=True) should_use_cpu_multiprocessing: bpy.props.BoolProperty(name="Import with CPU Multiprocessing", default=True) @@ -140,7 +139,6 @@ class ImportIFC(bpy.types.Operator, ImportHelper): settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger) settings.should_import_type_representations = self.should_import_type_representations - settings.should_import_curves = self.should_import_curves settings.should_import_spaces = self.should_import_spaces settings.should_auto_set_workarounds = self.should_auto_set_workarounds settings.should_use_cpu_multiprocessing = self.should_use_cpu_multiprocessing