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.view3d.view_selected()
|
||||||
bpy.ops.object.select_all(action="DESELECT")
|
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"):
|
for pset in self.file.by_type("IfcPropertySet"):
|
||||||
if pset.Name != "BBIM_Array":
|
if pset.Name != "BBIM_Array":
|
||||||
continue
|
continue
|
||||||
@@ -1148,12 +1163,11 @@ class IfcImporter:
|
|||||||
for rel in pset.DefinesOccurrence:
|
for rel in pset.DefinesOccurrence:
|
||||||
element: ifcopenshell.entity_instance
|
element: ifcopenshell.entity_instance
|
||||||
for element in rel.RelatedObjects:
|
for element in rel.RelatedObjects:
|
||||||
if annotations_to_import is None:
|
if is_base_import:
|
||||||
# IfcAnnotations are not loaded during base import.
|
if element.is_a("IfcAnnotation") or element.is_a("IfcOpeningElement"):
|
||||||
if element.is_a("IfcAnnotation"):
|
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if element not in annotations_to_import:
|
if element not in elements_to_import:
|
||||||
continue
|
continue
|
||||||
for i in range(len(data)):
|
for i in range(len(data)):
|
||||||
tool.Blender.Modifier.Array.set_children_lock_state(element, i, True)
|
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.load_existing_meshes()
|
||||||
ifc_importer.material_creator.load_existing_materials()
|
ifc_importer.material_creator.load_existing_materials()
|
||||||
ifc_importer.create_generic_elements(elements)
|
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():
|
for obj in ifc_importer.added_data.values():
|
||||||
tool.Collector.assign(obj)
|
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]:
|
def load_openings(cls, openings: list[ifcopenshell.entity_instance]) -> Iterable[bpy.types.Object]:
|
||||||
if not openings:
|
if not openings:
|
||||||
return []
|
return []
|
||||||
|
elements = set(openings)
|
||||||
ifc_import_settings = import_ifc.IfcImportSettings.factory()
|
ifc_import_settings = import_ifc.IfcImportSettings.factory()
|
||||||
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
ifc_importer = import_ifc.IfcImporter(ifc_import_settings)
|
||||||
ifc_importer.file = tool.Ifc.get()
|
ifc_importer.file = tool.Ifc.get()
|
||||||
ifc_importer.calculate_unit_scale()
|
ifc_importer.calculate_unit_scale()
|
||||||
ifc_importer.process_context_filter()
|
ifc_importer.process_context_filter()
|
||||||
ifc_importer.material_creator.load_existing_materials()
|
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():
|
for opening_obj in ifc_importer.added_data.values():
|
||||||
tool.Collector.assign(opening_obj, should_clean_users_collection=False)
|
tool.Collector.assign(opening_obj, should_clean_users_collection=False)
|
||||||
return ifc_importer.added_data.values()
|
return ifc_importer.added_data.values()
|
||||||
|
|||||||
Reference in New Issue
Block a user