mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Add feature to merge by material when importing, useful for artists
This commit is contained in:
@@ -165,6 +165,8 @@ class IfcImporter():
|
||||
self.create_products()
|
||||
if self.ifc_import_settings.should_merge_by_class:
|
||||
self.merge_by_class()
|
||||
elif self.ifc_import_settings.should_merge_by_material:
|
||||
self.merge_by_material()
|
||||
|
||||
def auto_set_workarounds(self):
|
||||
applications = self.file.by_type('IfcApplication')
|
||||
@@ -345,6 +347,18 @@ class IfcImporter():
|
||||
for obj in self.added_objects:
|
||||
if '/' in obj.name:
|
||||
merge_set.setdefault(obj.name.split('/')[0], []).append(obj)
|
||||
self.merge_objects(merge_set)
|
||||
|
||||
def merge_by_material(self):
|
||||
merge_set = {}
|
||||
for obj in self.added_objects:
|
||||
if not obj.material_slots:
|
||||
merge_set.setdefault('no-material', []).append(obj)
|
||||
else:
|
||||
merge_set.setdefault(obj.material_slots[0].name, []).append(obj)
|
||||
self.merge_objects(merge_set)
|
||||
|
||||
def merge_objects(self, merge_set):
|
||||
for ifc_class, objs in merge_set.items():
|
||||
context_override = {}
|
||||
context_override['object'] = context_override['active_object'] = objs[0]
|
||||
@@ -702,4 +716,5 @@ class IfcImportSettings:
|
||||
self.should_use_cpu_multiprocessing = False
|
||||
self.should_use_legacy = False
|
||||
self.should_merge_by_class = False
|
||||
self.should_merge_by_material = False
|
||||
self.diff_file = None
|
||||
|
||||
@@ -102,6 +102,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
||||
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_merge_by_class = bpy.context.scene.BIMProperties.import_should_merge_by_class
|
||||
ifc_import_settings.should_merge_by_material = bpy.context.scene.BIMProperties.import_should_merge_by_material
|
||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||
ifc_importer.execute()
|
||||
ifc_import_settings.logger.info('Import finished in {:.2f} seconds'.format(time.time() - start))
|
||||
|
||||
@@ -383,6 +383,7 @@ class BIMProperties(PropertyGroup):
|
||||
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_merge_by_class: BoolProperty(name="Import and Merge by Class", default=False)
|
||||
import_should_merge_by_material: BoolProperty(name="Import and Merge by Material", default=False)
|
||||
qa_reject_element_reason: StringProperty(name="Element Rejection Reason")
|
||||
person: EnumProperty(items=getPersons, name="Person")
|
||||
organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
||||
|
||||
@@ -647,6 +647,8 @@ class BIM_PT_mvd(Panel):
|
||||
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, 'import_should_merge_by_class')
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, 'import_should_merge_by_material')
|
||||
|
||||
layout.label(text='Vendor Workarounds:')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user