From 9961f6172f83dfff6e72554494fff471489971dc Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 12 Jun 2020 21:46:28 +1000 Subject: [PATCH] Users can now choose whether to import type representations, disabled by default --- src/ifcblenderexport/blenderbim/bim/import_ifc.py | 11 +++++++---- src/ifcblenderexport/blenderbim/bim/prop.py | 1 + src/ifcblenderexport/blenderbim/bim/ui.py | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index 92cf4c360e..b69f0a3671 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -286,7 +286,8 @@ class IfcImporter(): self.create_georeferencing() self.create_groups() self.create_grids() - self.create_native_products() + if self.ifc_import_settings.should_import_native: + self.create_native_products() # TODO: Deprecate after bug #682 is fixed and the new importer is stable if self.ifc_import_settings.should_use_legacy: self.create_products_legacy() @@ -570,7 +571,7 @@ class IfcImporter(): return representation_map = self.get_type_product_body_representation_map(element) mesh = None - if representation_map: + if self.ifc_import_settings.should_import_type_representations and representation_map: try: shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation) mesh_name = f'mesh-{shape.id}' @@ -607,7 +608,7 @@ class IfcImporter(): self.create_product_legacy(element) def create_native_products(self): - if not self.ifc_import_settings.should_import_native or not self.native_elements: + if not self.native_elements: return iterator = ifcopenshell.geom.iterator( self.settings_native, self.file, multiprocessing.cpu_count(), @@ -965,7 +966,7 @@ class IfcImporter(): if obj.type == 'MESH': obj.select_set(True) last_obj = obj - if not obj: + if not last_obj: return bpy.context.view_layer.objects.active = last_obj context_override = {} @@ -1734,6 +1735,7 @@ class IfcImportSettings: self.should_ignore_building_coordinates = False self.should_reset_absolute_coordinates = False self.should_merge_materials_by_colour = False + self.should_import_type_representations = False self.should_import_curves = False self.should_import_opening_elements = False self.should_import_spaces = False @@ -1760,6 +1762,7 @@ class IfcImportSettings: settings.should_ignore_site_coordinates = scene_bim.import_should_ignore_site_coordinates settings.should_ignore_building_coordinates = scene_bim.import_should_ignore_building_coordinates settings.should_reset_absolute_coordinates = scene_bim.import_should_reset_absolute_coordinates + settings.should_import_type_representations = scene_bim.import_should_import_type_representations settings.should_import_curves = scene_bim.import_should_import_curves settings.should_import_opening_elements = scene_bim.import_should_import_opening_elements settings.should_import_spaces = scene_bim.import_should_import_spaces diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 3a6b3a690e..c0e6491c4d 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -890,6 +890,7 @@ class BIMProperties(PropertyGroup): import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False) import_should_ignore_building_coordinates: BoolProperty(name="Import Ignoring Building Coordinates", default=False) import_should_reset_absolute_coordinates: BoolProperty(name="Import Resetting Absolute Coordinates", default=False) + import_should_import_type_representations: BoolProperty(name="Import Type Representations", default=False) import_should_import_curves: BoolProperty(name="Import Curves", default=False) import_should_import_opening_elements: BoolProperty(name="Import Opening Elements", default=False) import_should_import_spaces: BoolProperty(name="Import Spaces", default=False) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 4fc552327c..5d52197e5e 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -1187,6 +1187,8 @@ class BIM_PT_mvd(Panel): row = layout.row() row.prop(bim_properties, 'export_has_representations') row = layout.row() + row.prop(bim_properties, 'import_should_import_type_representations') + row = layout.row() row.prop(bim_properties, 'import_should_import_curves') row = layout.row() row.prop(bim_properties, 'import_should_import_opening_elements')