mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Add new feature to auto-clean mesh on import
This commit is contained in:
@@ -168,6 +168,8 @@ class IfcImporter():
|
||||
self.merge_by_class()
|
||||
elif self.ifc_import_settings.should_merge_by_material:
|
||||
self.merge_by_material()
|
||||
if self.ifc_import_settings.should_clean_mesh:
|
||||
self.clean_mesh()
|
||||
|
||||
def auto_set_workarounds(self):
|
||||
applications = self.file.by_type('IfcApplication')
|
||||
@@ -366,6 +368,17 @@ class IfcImporter():
|
||||
context_override['selected_objects'] = context_override['selected_editable_objects'] = objs
|
||||
bpy.ops.object.join(context_override)
|
||||
|
||||
def clean_mesh(self):
|
||||
for obj in self.added_objects:
|
||||
obj.select_set(True)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
context_override = {}
|
||||
bpy.ops.object.editmode_toggle(context_override)
|
||||
bpy.ops.mesh.remove_doubles(context_override)
|
||||
bpy.ops.mesh.tris_convert_to_quads(context_override)
|
||||
bpy.ops.mesh.normals_make_consistent(context_override)
|
||||
bpy.ops.object.editmode_toggle(context_override)
|
||||
|
||||
def add_product_psets(self, element, obj):
|
||||
if not hasattr(element, 'IsDefinedBy') or not element.IsDefinedBy:
|
||||
return
|
||||
@@ -724,4 +737,5 @@ class IfcImportSettings:
|
||||
self.should_merge_by_class = False
|
||||
self.should_merge_by_material = False
|
||||
self.should_import_aggregates = True
|
||||
self.should_clean_mesh = True
|
||||
self.diff_file = None
|
||||
|
||||
@@ -104,6 +104,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
||||
ifc_import_settings.should_import_aggregates = bpy.context.scene.BIMProperties.import_should_import_aggregates
|
||||
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_import_settings.should_clean_mesh = bpy.context.scene.BIMProperties.import_should_clean_mesh
|
||||
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))
|
||||
|
||||
@@ -385,6 +385,7 @@ class BIMProperties(PropertyGroup):
|
||||
import_should_import_aggregates: BoolProperty(name="Import Aggregates", default=True)
|
||||
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)
|
||||
import_should_clean_mesh: BoolProperty(name="Import and Clean Mesh", default=True)
|
||||
qa_reject_element_reason: StringProperty(name="Element Rejection Reason")
|
||||
person: EnumProperty(items=getPersons, name="Person")
|
||||
organisation: EnumProperty(items=getOrganisations, name="Organisation")
|
||||
|
||||
@@ -651,6 +651,8 @@ class BIM_PT_mvd(Panel):
|
||||
row.prop(bim_properties, 'import_should_merge_by_class')
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, 'import_should_merge_by_material')
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, 'import_should_clean_mesh')
|
||||
|
||||
layout.label(text='Vendor Workarounds:')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user