mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Skip IfcOpeningElements arrays during base import, setup constraint on opening load #6688
This commit is contained in:
@@ -1138,7 +1138,22 @@ class IfcImporter:
|
||||
bpy.ops.view3d.view_selected()
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
|
||||
def setup_arrays(self, annotations_to_import: Optional[set[ifcopenshell.entity_instance]] = None) -> None:
|
||||
def setup_arrays(
|
||||
self,
|
||||
*,
|
||||
annotations_to_import: Optional[set[ifcopenshell.entity_instance]] = None,
|
||||
openings_to_import: Optional[set[ifcopenshell.entity_instance]] = None,
|
||||
) -> None:
|
||||
# During base import some elements are skipped.
|
||||
is_base_import = True
|
||||
elements_to_import: set[ifcopenshell.entity_instance] = set()
|
||||
if annotations_to_import is not None:
|
||||
is_base_import = False
|
||||
elements_to_import = annotations_to_import
|
||||
elif openings_to_import is not None:
|
||||
is_base_import = False
|
||||
elements_to_import = openings_to_import
|
||||
|
||||
for pset in self.file.by_type("IfcPropertySet"):
|
||||
if pset.Name != "BBIM_Array":
|
||||
continue
|
||||
@@ -1148,12 +1163,11 @@ class IfcImporter:
|
||||
for rel in pset.DefinesOccurrence:
|
||||
element: ifcopenshell.entity_instance
|
||||
for element in rel.RelatedObjects:
|
||||
if annotations_to_import is None:
|
||||
# IfcAnnotations are not loaded during base import.
|
||||
if element.is_a("IfcAnnotation"):
|
||||
if is_base_import:
|
||||
if element.is_a("IfcAnnotation") or element.is_a("IfcOpeningElement"):
|
||||
continue
|
||||
else:
|
||||
if element not in annotations_to_import:
|
||||
if element not in elements_to_import:
|
||||
continue
|
||||
for i in range(len(data)):
|
||||
tool.Blender.Modifier.Array.set_children_lock_state(element, i, True)
|
||||
|
||||
@@ -785,7 +785,7 @@ class Drawing(bonsai.core.tool.Drawing):
|
||||
ifc_importer.load_existing_meshes()
|
||||
ifc_importer.material_creator.load_existing_materials()
|
||||
ifc_importer.create_generic_elements(elements)
|
||||
ifc_importer.setup_arrays(elements)
|
||||
ifc_importer.setup_arrays(annotations_to_import=elements)
|
||||
for obj in ifc_importer.added_data.values():
|
||||
tool.Collector.assign(obj)
|
||||
|
||||
|
||||
@@ -587,13 +587,15 @@ class Model(bonsai.core.tool.Model):
|
||||
def load_openings(cls, openings: list[ifcopenshell.entity_instance]) -> Iterable[bpy.types.Object]:
|
||||
if not openings:
|
||||
return []
|
||||
elements = set(openings)
|
||||
ifc_import_settings = import_ifc.IfcImportSettings.factory()
|
||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||
ifc_importer.file = tool.Ifc.get()
|
||||
ifc_importer.calculate_unit_scale()
|
||||
ifc_importer.process_context_filter()
|
||||
ifc_importer.material_creator.load_existing_materials()
|
||||
ifc_importer.create_generic_elements(set(openings))
|
||||
ifc_importer.create_generic_elements(elements)
|
||||
ifc_importer.setup_arrays(openings_to_import=elements)
|
||||
for opening_obj in ifc_importer.added_data.values():
|
||||
tool.Collector.assign(opening_obj, should_clean_users_collection=False)
|
||||
return ifc_importer.added_data.values()
|
||||
|
||||
Reference in New Issue
Block a user