mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
New feature to merge import geometry by class, which is useful for artists who don't care too much about the data
This commit is contained in:
@@ -138,6 +138,7 @@ class IfcImporter():
|
|||||||
self.mesh_shapes = {}
|
self.mesh_shapes = {}
|
||||||
self.time = 0
|
self.time = 0
|
||||||
self.unit_scale = 1
|
self.unit_scale = 1
|
||||||
|
self.added_objects = []
|
||||||
|
|
||||||
self.material_creator = MaterialCreator(ifc_import_settings)
|
self.material_creator = MaterialCreator(ifc_import_settings)
|
||||||
|
|
||||||
@@ -162,6 +163,8 @@ class IfcImporter():
|
|||||||
self.create_products_legacy()
|
self.create_products_legacy()
|
||||||
else:
|
else:
|
||||||
self.create_products()
|
self.create_products()
|
||||||
|
if self.ifc_import_settings.should_merge_by_class:
|
||||||
|
self.merge_by_class()
|
||||||
|
|
||||||
def auto_set_workarounds(self):
|
def auto_set_workarounds(self):
|
||||||
applications = self.file.by_type('IfcApplication')
|
applications = self.file.by_type('IfcApplication')
|
||||||
@@ -335,6 +338,18 @@ class IfcImporter():
|
|||||||
self.add_defines_by_type_relation(element, obj)
|
self.add_defines_by_type_relation(element, obj)
|
||||||
self.place_object_in_spatial_tree(element, obj)
|
self.place_object_in_spatial_tree(element, obj)
|
||||||
self.add_product_psets(element, obj)
|
self.add_product_psets(element, obj)
|
||||||
|
self.added_objects.append(obj)
|
||||||
|
|
||||||
|
def merge_by_class(self):
|
||||||
|
merge_set = {}
|
||||||
|
for obj in self.added_objects:
|
||||||
|
if '/' in obj.name:
|
||||||
|
merge_set.setdefault(obj.name.split('/')[0], []).append(obj)
|
||||||
|
for ifc_class, objs in merge_set.items():
|
||||||
|
context_override = {}
|
||||||
|
context_override['object'] = context_override['active_object'] = objs[0]
|
||||||
|
context_override['selected_objects'] = context_override['selected_editable_objects'] = objs
|
||||||
|
bpy.ops.object.join(context_override)
|
||||||
|
|
||||||
def add_product_psets(self, element, obj):
|
def add_product_psets(self, element, obj):
|
||||||
if not hasattr(element, 'IsDefinedBy') or not element.IsDefinedBy:
|
if not hasattr(element, 'IsDefinedBy') or not element.IsDefinedBy:
|
||||||
@@ -686,4 +701,5 @@ class IfcImportSettings:
|
|||||||
self.should_treat_styled_item_as_material = False
|
self.should_treat_styled_item_as_material = False
|
||||||
self.should_use_cpu_multiprocessing = False
|
self.should_use_cpu_multiprocessing = False
|
||||||
self.should_use_legacy = False
|
self.should_use_legacy = False
|
||||||
|
self.should_merge_by_class = False
|
||||||
self.diff_file = None
|
self.diff_file = None
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
|||||||
ifc_import_settings.should_treat_styled_item_as_material = bpy.context.scene.BIMProperties.import_should_treat_styled_item_as_material
|
ifc_import_settings.should_treat_styled_item_as_material = bpy.context.scene.BIMProperties.import_should_treat_styled_item_as_material
|
||||||
ifc_import_settings.should_use_cpu_multiprocessing = bpy.context.scene.BIMProperties.import_should_use_cpu_multiprocessing
|
ifc_import_settings.should_use_cpu_multiprocessing = bpy.context.scene.BIMProperties.import_should_use_cpu_multiprocessing
|
||||||
ifc_import_settings.should_use_legacy = bpy.context.scene.BIMProperties.import_should_use_legacy
|
ifc_import_settings.should_use_legacy = bpy.context.scene.BIMProperties.import_should_use_legacy
|
||||||
|
ifc_import_settings.should_merge_by_class = bpy.context.scene.BIMProperties.import_should_merge_by_class
|
||||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||||
ifc_importer.execute()
|
ifc_importer.execute()
|
||||||
ifc_import_settings.logger.info('Import finished in {:.2f} seconds'.format(time.time() - start))
|
ifc_import_settings.logger.info('Import finished in {:.2f} seconds'.format(time.time() - start))
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ class BIMProperties(PropertyGroup):
|
|||||||
import_should_treat_styled_item_as_material: BoolProperty(name="Import Treating Styled Item as Material", default=False)
|
import_should_treat_styled_item_as_material: BoolProperty(name="Import Treating Styled Item as Material", default=False)
|
||||||
import_should_use_legacy: BoolProperty(name="Import with Legacy Importer", default=False)
|
import_should_use_legacy: BoolProperty(name="Import with Legacy Importer", default=False)
|
||||||
import_should_use_cpu_multiprocessing: BoolProperty(name="Import with CPU Multiprocessing", default=False)
|
import_should_use_cpu_multiprocessing: BoolProperty(name="Import with CPU Multiprocessing", default=False)
|
||||||
|
import_should_merge_by_class: BoolProperty(name="Import and Merge by Class", default=False)
|
||||||
qa_reject_element_reason: StringProperty(name="Element Rejection Reason")
|
qa_reject_element_reason: StringProperty(name="Element Rejection Reason")
|
||||||
person: EnumProperty(items=getPersons, name="Person")
|
person: EnumProperty(items=getPersons, name="Person")
|
||||||
organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
||||||
|
|||||||
@@ -643,6 +643,11 @@ class BIM_PT_mvd(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bim_properties, 'import_should_use_cpu_multiprocessing')
|
row.prop(bim_properties, 'import_should_use_cpu_multiprocessing')
|
||||||
|
|
||||||
|
layout.label(text='Simplifications:')
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bim_properties, 'import_should_merge_by_class')
|
||||||
|
|
||||||
layout.label(text='Vendor Workarounds:')
|
layout.label(text='Vendor Workarounds:')
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user