Type representations are now always imported (better for authoring), and also import super fast compared to before (before, enabling types being imported would significantly slow down import times)

This commit is contained in:
Dion Moult
2021-02-07 19:57:32 +11:00
parent 23483eafb3
commit d08f4171e3
2 changed files with 15 additions and 17 deletions
@@ -335,8 +335,6 @@ class IfcImporter:
self.profile_code("Create project") self.profile_code("Create project")
self.create_spatial_hierarchy() self.create_spatial_hierarchy()
self.profile_code("Create spatial hierarchy") self.profile_code("Create spatial hierarchy")
self.create_type_products()
self.profile_code("Create type products")
self.create_aggregates() self.create_aggregates()
self.profile_code("Create aggregates") self.profile_code("Create aggregates")
self.create_openings_collection() self.create_openings_collection()
@@ -347,14 +345,16 @@ class IfcImporter:
# self.parse_native_elements() # self.parse_native_elements()
# self.profile_code("Parsing native elements") # self.profile_code("Parsing native elements")
self.create_grids() self.create_grids()
self.profile_code("Creating grids") self.profile_code("Create grids")
# TODO: Deprecate # TODO: Deprecate
# self.create_native_products() # self.create_native_products()
# self.profile_code("Creating native products") # self.profile_code("Create native products")
self.create_products() self.create_products()
self.profile_code("Creating meshified products") self.profile_code("Create products")
self.create_type_products()
self.profile_code("Create type products")
self.create_annotation() self.create_annotation()
self.profile_code("Creating annotation") self.profile_code("Create annotation")
self.place_objects_in_spatial_tree() self.place_objects_in_spatial_tree()
self.profile_code("Placing objects in spatial tree") self.profile_code("Placing objects in spatial tree")
if self.ifc_import_settings.should_merge_by_class: if self.ifc_import_settings.should_merge_by_class:
@@ -633,16 +633,17 @@ class IfcImporter:
return return
representation_map = self.get_type_product_body_representation_map(element) representation_map = self.get_type_product_body_representation_map(element)
mesh = None mesh = None
if self.ifc_import_settings.should_import_type_representations and representation_map: if representation_map:
try: representation = representation_map.MappedRepresentation
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation) mesh_name = "{}/{}".format(representation.ContextOfItems.id(), representation.id())
mesh_name = self.get_mesh_name(shape) mesh = self.meshes.get(mesh_name)
mesh = self.meshes.get(mesh_name) if mesh is None:
if mesh is None: try:
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation)
mesh = self.create_mesh(element, shape) mesh = self.create_mesh(element, shape)
self.meshes[mesh_name] = mesh self.meshes[mesh_name] = mesh
except: except:
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element) self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
obj = bpy.data.objects.new(self.get_name(element), mesh) obj = bpy.data.objects.new(self.get_name(element), mesh)
obj.BIMObjectProperties.ifc_definition_id = element.id() obj.BIMObjectProperties.ifc_definition_id = element.id()
self.material_creator.create(element, obj, mesh) self.material_creator.create(element, obj, mesh)
@@ -1576,7 +1577,6 @@ class IfcImportSettings:
self.logger = None self.logger = None
self.input_file = None self.input_file = None
self.diff_file = None self.diff_file = None
self.should_import_type_representations = False
self.should_import_spaces = False self.should_import_spaces = False
self.should_auto_set_workarounds = True self.should_auto_set_workarounds = True
self.should_use_cpu_multiprocessing = True self.should_use_cpu_multiprocessing = True
@@ -111,7 +111,6 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
filename_ext = ".ifc" filename_ext = ".ifc"
filter_glob: bpy.props.StringProperty(default="*.ifc;*.ifczip;*.ifcxml", options={"HIDDEN"}) 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_spaces: bpy.props.BoolProperty(name="Import Spaces", 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_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) should_use_cpu_multiprocessing: bpy.props.BoolProperty(name="Import with CPU Multiprocessing", default=True)
@@ -138,7 +137,6 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
) )
settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger) settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger)
settings.should_import_type_representations = self.should_import_type_representations
settings.should_import_spaces = self.should_import_spaces settings.should_import_spaces = self.should_import_spaces
settings.should_auto_set_workarounds = self.should_auto_set_workarounds settings.should_auto_set_workarounds = self.should_auto_set_workarounds
settings.should_use_cpu_multiprocessing = self.should_use_cpu_multiprocessing settings.should_use_cpu_multiprocessing = self.should_use_cpu_multiprocessing