mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
You can now toggle whether element filtering also affects spatial containers
This commit is contained in:
@@ -290,9 +290,12 @@ class IfcImporter:
|
||||
def process_element_filter(self):
|
||||
if self.ifc_import_settings.has_filter:
|
||||
self.elements = set(self.ifc_import_settings.elements)
|
||||
self.spatial_elements = self.get_spatial_elements_filtered_by_elements(self.elements)
|
||||
else:
|
||||
self.elements = set(self.file.by_type("IfcElement"))
|
||||
|
||||
if self.ifc_import_settings.has_filter and self.ifc_import_settings.should_filter_spatial_elements:
|
||||
self.spatial_elements = self.get_spatial_elements_filtered_by_elements(self.elements)
|
||||
else:
|
||||
if self.file.schema == "IFC2X3":
|
||||
self.spatial_elements = set(self.file.by_type("IfcSpatialStructureElement"))
|
||||
else:
|
||||
@@ -581,19 +584,17 @@ class IfcImporter:
|
||||
print("Done creating geometry")
|
||||
|
||||
def create_spatial_elements(self):
|
||||
products = self.create_products(self.spatial_elements)
|
||||
self.spatial_elements -= products
|
||||
products = self.create_curve_products(self.spatial_elements)
|
||||
self.spatial_elements -= products
|
||||
for element in self.spatial_elements:
|
||||
self.create_product(element)
|
||||
self.create_generic_elements(self.spatial_elements)
|
||||
|
||||
def create_elements(self):
|
||||
products = self.create_products(self.elements)
|
||||
self.elements -= products
|
||||
products = self.create_curve_products(self.elements)
|
||||
self.elements -= products
|
||||
for element in self.elements:
|
||||
self.create_generic_elements(self.elements)
|
||||
|
||||
def create_generic_elements(self, elements):
|
||||
products = self.create_products(elements)
|
||||
elements -= products
|
||||
products = self.create_curve_products(elements)
|
||||
elements -= products
|
||||
for element in elements:
|
||||
self.create_product(element)
|
||||
|
||||
def create_products(self, products):
|
||||
@@ -1438,14 +1439,30 @@ class IfcImportSettings:
|
||||
self.should_offset_model = False
|
||||
self.model_offset_coordinates = (0, 0, 0)
|
||||
self.has_filter = None
|
||||
self.elements = ""
|
||||
self.should_filter_spatial_elements = True
|
||||
self.elements = set()
|
||||
self.collection_mode = "DECOMPOSITION"
|
||||
|
||||
@staticmethod
|
||||
def factory(context, input_file, logger):
|
||||
scene_diff = context.scene.DiffProperties
|
||||
props = context.scene.BIMProjectProperties
|
||||
settings = IfcImportSettings()
|
||||
settings.input_file = input_file
|
||||
settings.logger = logger
|
||||
settings.diff_file = scene_diff.diff_json_file
|
||||
settings.collection_mode = props.collection_mode
|
||||
settings.should_use_cpu_multiprocessing = props.should_use_cpu_multiprocessing
|
||||
settings.should_merge_by_class = props.should_merge_by_class
|
||||
settings.should_merge_by_material = props.should_merge_by_material
|
||||
settings.should_merge_materials_by_colour = props.should_merge_materials_by_colour
|
||||
settings.should_clean_mesh = props.should_clean_mesh
|
||||
settings.deflection_tolerance = props.deflection_tolerance
|
||||
settings.angular_tolerance = props.angular_tolerance
|
||||
settings.should_offset_model = props.should_offset_model
|
||||
settings.model_offset_coordinates = (
|
||||
[float(o) for o in props.model_offset_coordinates.split(",")]
|
||||
if props.model_offset_coordinates
|
||||
else (0, 0, 0)
|
||||
)
|
||||
return settings
|
||||
|
||||
@@ -586,6 +586,7 @@ class LoadProjectElements(bpy.types.Operator):
|
||||
)
|
||||
settings = import_ifc.IfcImportSettings.factory(context, context.scene.BIMProperties.ifc_file, logger)
|
||||
settings.has_filter = self.props.filter_mode != "NONE"
|
||||
settings.should_filter_spatial_elements = self.props.should_filter_spatial_elements
|
||||
if self.props.filter_mode == "DECOMPOSITION":
|
||||
settings.elements = self.get_decomposition_elements()
|
||||
elif self.props.filter_mode == "IFC_CLASS":
|
||||
@@ -594,20 +595,6 @@ class LoadProjectElements(bpy.types.Operator):
|
||||
settings.elements = self.get_whitelist_elements()
|
||||
elif self.props.filter_mode == "BLACKLIST":
|
||||
settings.elements = self.get_blacklist_elements()
|
||||
settings.collection_mode = self.props.collection_mode
|
||||
settings.should_use_cpu_multiprocessing = self.props.should_use_cpu_multiprocessing
|
||||
settings.should_merge_by_class = self.props.should_merge_by_class
|
||||
settings.should_merge_by_material = self.props.should_merge_by_material
|
||||
settings.should_merge_materials_by_colour = self.props.should_merge_materials_by_colour
|
||||
settings.should_clean_mesh = self.props.should_clean_mesh
|
||||
settings.deflection_tolerance = self.props.deflection_tolerance
|
||||
settings.angular_tolerance = self.props.angular_tolerance
|
||||
settings.should_offset_model = self.props.should_offset_model
|
||||
settings.model_offset_coordinates = (
|
||||
[float(o) for o in self.props.model_offset_coordinates.split(",")]
|
||||
if self.props.model_offset_coordinates
|
||||
else (0, 0, 0)
|
||||
)
|
||||
settings.logger.info("Starting import")
|
||||
ifc_importer = import_ifc.IfcImporter(settings)
|
||||
ifc_importer.execute()
|
||||
|
||||
@@ -107,6 +107,7 @@ class BIMProjectProperties(PropertyGroup):
|
||||
filter_categories: CollectionProperty(name="Filter Categories", type=FilterCategory)
|
||||
active_filter_category_index: IntProperty(name="Active Filter Category Index")
|
||||
filter_query: StringProperty(name="Filter Query")
|
||||
should_filter_spatial_elements: BoolProperty(name="Filter Spatial Elements", default=True)
|
||||
should_use_cpu_multiprocessing: BoolProperty(name="Import with CPU Multiprocessing", default=True)
|
||||
should_merge_by_class: BoolProperty(name="Import and Merge by Class", default=False)
|
||||
should_merge_by_material: BoolProperty(name="Import and Merge by Material", default=False)
|
||||
|
||||
@@ -59,6 +59,9 @@ class BIM_PT_project(Panel):
|
||||
elif pprops.filter_mode in ["WHITELIST", "BLACKLIST"]:
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "filter_query")
|
||||
if pprops.filter_mode != "NONE":
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "should_filter_spatial_elements")
|
||||
row = self.layout.row()
|
||||
row.prop(pprops, "should_use_cpu_multiprocessing")
|
||||
row = self.layout.row()
|
||||
|
||||
@@ -51,12 +51,13 @@ class BIM_PT_spatial(Panel):
|
||||
if SpatialData.data["parent_container_id"]:
|
||||
op = row.operator("bim.change_spatial_level", text="", icon="FRAME_PREV")
|
||||
op.parent = SpatialData.data["parent_container_id"]
|
||||
op = row.operator("bim.assign_container", icon="CHECKMARK")
|
||||
op.structure = props.containers[props.active_container_index].ifc_definition_id
|
||||
if props.active_container_index <= len(props.containers):
|
||||
op = row.operator("bim.assign_container", icon="CHECKMARK")
|
||||
op.structure = props.containers[props.active_container_index].ifc_definition_id
|
||||
row.operator("bim.copy_to_container", icon="COPYDOWN", text="")
|
||||
row.operator("bim.disable_editing_container", icon="CANCEL", text="")
|
||||
|
||||
self.layout.template_list("BIM_UL_containers", "", props, "containers", props, "active_container_id")
|
||||
self.layout.template_list("BIM_UL_containers", "", props, "containers", props, "active_container_index")
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
if SpatialData.data["is_contained"]:
|
||||
|
||||
Reference in New Issue
Block a user