Support import whitelists and blacklist filters. Groundwork for #865.

This commit is contained in:
Dion Moult
2020-06-11 10:52:00 +10:00
parent 4a6868495e
commit edc3aa6157
5 changed files with 60 additions and 7 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ endif
mkdir -p dist/blenderbim
cp -r blenderbim/* dist/blenderbim/
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcblender-python-37-v0.6.0-0d93633-$(PLATFORM)64.zip
cd dist/working && wget https://s3.amazonaws.com/ifcopenshell-builds/ifcblender-python-37-v0.6.0-793c1c8-$(PLATFORM)64.zip
cd dist/working && unzip ifcblender*
cp -r dist/working/io_import_scene_ifc/ifcopenshell dist/blenderbim/libs/site/packages/
# See bug #812
@@ -169,6 +169,7 @@ if bpy is not None:
prop.BoundaryCondition,
prop.PsetQto,
prop.GlobalId,
prop.RepresentationItem,
prop.BIMObjectProperties,
prop.BIMMaterialProperties,
prop.SweptSolid,
@@ -205,6 +206,7 @@ if bpy is not None:
ui.BIM_UL_document_references,
ui.BIM_UL_topics,
ui.BIM_UL_classifications,
ui.BIM_UL_representation_items,
ui.BIM_ADDON_preferences,
covetool_prop.CoveToolProject,
covetool_prop.CoveToolSimpleAnalysis,
@@ -1,5 +1,6 @@
import ifcopenshell
import ifcopenshell.geom
import ifcopenshell.util.selector
import bpy
import bmesh
import os
@@ -229,12 +230,15 @@ class IfcImporter():
self.settings_2d = ifcopenshell.geom.settings()
self.settings_2d.set(self.settings_2d.INCLUDE_CURVES, True)
self.existing_elements = {}
self.include_elements = []
self.exclude_elements = []
self.project = None
self.classifications = {}
self.spatial_structure_elements = {}
self.elements = {}
self.type_collection = None
self.type_products = {}
self.openings = {}
self.meshes = {}
self.mesh_shapes = {}
self.time = 0
@@ -269,8 +273,9 @@ class IfcImporter():
self.create_aggregates()
if self.ifc_import_settings.should_import_opening_elements:
self.create_openings_collection()
self.process_element_filter()
if self.ifc_import_settings.should_import_native:
self.parse_native_products()
self.parse_native_elements()
self.filter_ifc()
self.patch_ifc()
self.create_georeferencing()
@@ -331,8 +336,18 @@ class IfcImporter():
or abs(point.Coordinates[1]) > 1000000 \
or abs(point.Coordinates[2]) > 1000000
def process_element_filter(self):
if not self.ifc_import_settings.ifc_selector:
return
self.include_elements = []
selector = ifcopenshell.util.selector.Selector()
elements = selector.parse(self.file, self.ifc_import_settings.ifc_selector)
if self.ifc_import_settings.ifc_import_filter == 'WHITELIST':
self.include_elements = elements
elif self.ifc_import_settings.ifc_import_filter == 'BLACKLIST':
self.exclude_elements = elements
def parse_native_products(self):
def parse_native_elements(self):
self.parse_native_swept_disk_solid()
self.parse_native_extruded_area_solid()
@@ -573,12 +588,18 @@ class IfcImporter():
def create_products(self):
if self.ifc_import_settings.should_use_cpu_multiprocessing:
iterator = ifcopenshell.geom.iterator(self.settings, self.file, multiprocessing.cpu_count())
iterator = ifcopenshell.geom.iterator(
self.settings, self.file, multiprocessing.cpu_count(),
include=self.include_elements or None,
exclude=self.exclude_elements or None
)
else:
iterator = ifcopenshell.geom.iterator(self.settings, self.file)
iterator = ifcopenshell.geom.iterator(
self.settings, self.file,
include=self.include_elements or None,
exclude=self.exclude_elements or None)
valid_file = iterator.initialize()
if not valid_file:
self.create_products_legacy() # Sometimes, this can still work, not 100% sure why yet
return False
old_progress = -1
while True:
@@ -1692,6 +1713,8 @@ class IfcImportSettings:
settings.input_file = input_file
settings.logger = logger
settings.diff_file = scene_bim.diff_json_file
settings.ifc_import_filter = scene_bim.ifc_import_filter
settings.ifc_selector = scene_bim.ifc_selector
settings.should_ignore_site_coordinates = scene_bim.import_should_ignore_site_coordinates
settings.should_ignore_building_coordinates = scene_bim.import_should_ignore_building_coordinates
settings.should_reset_absolute_coordinates = scene_bim.import_should_reset_absolute_coordinates
+13 -1
View File
@@ -890,7 +890,7 @@ class BIMProperties(PropertyGroup):
import_should_ignore_site_coordinates: BoolProperty(name="Import Ignoring Site Coordinates", default=False)
import_should_ignore_building_coordinates: BoolProperty(name="Import Ignoring Building Coordinates", default=False)
import_should_reset_absolute_coordinates: BoolProperty(name="Import Resetting Absolute Coordinates", default=False)
import_should_import_curves: BoolProperty(name="Import Curves", default=True)
import_should_import_curves: BoolProperty(name="Import Curves", default=False)
import_should_import_opening_elements: BoolProperty(name="Import Opening Elements", default=False)
import_should_import_spaces: BoolProperty(name="Import Spaces", default=False)
import_should_auto_set_workarounds: BoolProperty(name="Automatically Set Vendor Workarounds", default=True)
@@ -942,6 +942,11 @@ class BIMProperties(PropertyGroup):
property_templates: CollectionProperty(name='Property Templates', type=PropertyTemplate)
should_section_selected_objects: BoolProperty(name="Section Selected Objects", default=False)
section_plane_colour: FloatVectorProperty(name='Temporary Section Cutaway Colour', subtype='COLOR', default=(1, 0, 0), min=0.0, max=1.0)
ifc_import_filter: EnumProperty(items=[
('NONE', 'None', ''),
('WHITELIST', 'Whitelist', ''),
('BLACKLIST', 'Blacklist', ''),
], name='Import Filter')
ifc_selector: StringProperty(default='', name='IFC Selector')
csv_attributes: CollectionProperty(name='CSV Attributes', type=StrProperty)
document_information: CollectionProperty(name='Document Information', type=DocumentInformation)
@@ -1069,6 +1074,11 @@ class SweptSolid(PropertyGroup):
extrusion: StringProperty(name="Extrusion")
class RepresentationItem(PropertyGroup):
name: StringProperty(name="Name")
vgroup: StringProperty(name="Vertex Group")
class BIMMeshProperties(PropertyGroup):
is_wireframe: BoolProperty(name="Is Wireframe")
is_swept_solid: BoolProperty(name="Is Swept Solid")
@@ -1076,3 +1086,5 @@ class BIMMeshProperties(PropertyGroup):
is_parametric: BoolProperty(name='Is Parametric', default=False)
presentation_layer: StringProperty(name="Presentation Layer")
geometry_type: StringProperty(name="Geometry Type")
representation_items: CollectionProperty(name="Representation Items", type=RepresentationItem)
active_representation_item_index: IntProperty(name='Active Representation Item Index')
+16
View File
@@ -427,6 +427,8 @@ class BIM_PT_mesh(Panel):
row = layout.row()
row.prop(props, 'geometry_type')
layout.template_list('BIM_UL_representation_items', '', props, 'representation_items', props, 'active_representation_item_index')
row = layout.row()
row.prop(props, 'presentation_layer')
@@ -1175,6 +1177,11 @@ class BIM_PT_mvd(Panel):
row = layout.row()
row.prop(bim_properties, 'export_schema')
row = layout.row()
row.prop(bim_properties, 'ifc_import_filter')
row = layout.row()
row.prop(bim_properties, 'ifc_selector')
layout.label(text='Custom MVD:')
row = layout.row()
@@ -1298,6 +1305,15 @@ class BIM_UL_classifications(bpy.types.UIList):
layout.label(text=itemdata['name'])
class BIM_UL_representation_items(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
ob = data
if item:
layout.prop(item, 'name', text='', emboss=False)
else:
layout.label(text="", translate=False)
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
bl_idname = 'blenderbim'