mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Automatically detect and set import workarounds for Revit
This commit is contained in:
@@ -147,6 +147,8 @@ class IfcImporter():
|
||||
def execute(self):
|
||||
self.load_diff()
|
||||
self.load_file()
|
||||
if self.ifc_import_settings.should_auto_set_workarounds:
|
||||
self.auto_set_workarounds()
|
||||
self.calculate_unit_scale()
|
||||
self.create_project()
|
||||
self.create_spatial_hierarchy()
|
||||
@@ -160,6 +162,28 @@ class IfcImporter():
|
||||
else:
|
||||
self.create_products()
|
||||
|
||||
def auto_set_workarounds(self):
|
||||
applications = self.file.by_type('IfcApplication')
|
||||
if not applications:
|
||||
return
|
||||
if applications[0].ApplicationIdentifier == 'Revit':
|
||||
self.ifc_import_settings.should_treat_styled_item_as_material = True
|
||||
if self.is_site_far_away():
|
||||
self.ifc_import_settings.should_ignore_site_coordinates = True
|
||||
|
||||
def is_site_far_away(self):
|
||||
for site in self.file.by_type('IfcSite'):
|
||||
if not site.ObjectPlacement \
|
||||
or not site.ObjectPlacement.RelativePlacement \
|
||||
or not site.ObjectPlacement.RelativePlacement.Location:
|
||||
continue
|
||||
coordinates = site.ObjectPlacement.RelativePlacement.Location.Coordinates
|
||||
# Arbitrary threshold based on experience
|
||||
if abs(coordinates[0]) > 1000000 \
|
||||
or abs(coordinates[1]) > 1000000 \
|
||||
or abs(coordinates[2]) > 1000000:
|
||||
return True
|
||||
|
||||
def patch_ifc(self):
|
||||
if self.ifc_import_settings.should_ignore_site_coordinates:
|
||||
project = self.file.by_type('IfcProject')[0]
|
||||
@@ -508,6 +532,7 @@ class IfcImportSettings:
|
||||
def __init__(self):
|
||||
self.logger = None
|
||||
self.input_file = None
|
||||
self.should_auto_set_workarounds = True
|
||||
self.should_ignore_site_coordinates = False
|
||||
self.should_import_curves = False
|
||||
self.should_treat_styled_item_as_material = False
|
||||
|
||||
@@ -79,6 +79,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
||||
ifc_import_settings.diff_file = bpy.context.scene.BIMProperties.diff_json_file
|
||||
ifc_import_settings.should_ignore_site_coordinates = bpy.context.scene.BIMProperties.import_should_ignore_site_coordinates
|
||||
ifc_import_settings.should_import_curves = bpy.context.scene.BIMProperties.import_should_import_curves
|
||||
ifc_import_settings.should_auto_set_workarounds = bpy.context.scene.BIMProperties.import_should_auto_set_workarounds
|
||||
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_legacy = bpy.context.scene.BIMProperties.import_should_use_legacy
|
||||
|
||||
@@ -253,6 +253,7 @@ class BIMProperties(PropertyGroup):
|
||||
export_should_use_presentation_style_assignment: BoolProperty(name="Export with Presentation Style Assignment", default=False)
|
||||
import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False)
|
||||
import_should_import_curves: BoolProperty(name="Import Curves", default=False)
|
||||
import_should_auto_set_workarounds: BoolProperty(name="Automatically Set Vendor Workarounds", default=True)
|
||||
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_cpu_multiprocessing: BoolProperty(name="Import with CPU Multiprocessing", default=False)
|
||||
|
||||
@@ -510,6 +510,8 @@ class BIM_PT_mvd(Panel):
|
||||
|
||||
layout.label(text="Revit Workarounds:")
|
||||
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, "import_should_auto_set_workarounds")
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, "export_should_export_all_materials_as_styled_items")
|
||||
row = layout.row()
|
||||
|
||||
Reference in New Issue
Block a user