Skip to content

Commit

Permalink
Fixed error importing .ifc that has element aggregated by ifcproject
Browse files Browse the repository at this point in the history
In case if some element (not another aggregate) was aggregated by IfcProject directly, importing IFC was resulting in error below since the project's collection was never added to `self.collections`.

Traceback:
```
  File "\scripts\addons\blenderbim\bim\module\project\operator.py", line 732, in execute
    ifc_importer.execute()
  File "\scripts\addons\blenderbim\bim\import_ifc.py", line 292, in execute
    self.place_objects_in_collections()
  File "\scripts\addons\blenderbim\bim\import_ifc.py", line 1668, in place_objects_in_collections
    self.place_object_in_collection(self.file.by_id(ifc_definition_id), obj)
  File "\scripts\addons\blenderbim\bim\import_ifc.py", line 1672, in place_object_in_collection
    self.place_object_in_decomposition_collection(element, obj)
  File "\scripts\addons\blenderbim\bim\import_ifc.py", line 1689, in place_object_in_decomposition_collection
    return self.collections[aggregate.GlobalId].objects.link(obj)
KeyError: '2bKVb8E7L6e89EQYJUk8BM'
```
  • Loading branch information
Andrej730 committed Nov 15, 2023
1 parent c0d2ac6 commit 2557580
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/blenderbim/blenderbim/bim/import_ifc.py
Expand Up @@ -1532,7 +1532,7 @@ def create_project(self):
obj = self.create_product(self.project["ifc"])
self.project["blender"].objects.link(obj)
self.project["blender"].BIMCollectionProperties.obj = obj
obj.BIMObjectProperties.collection = self.project["blender"]
obj.BIMObjectProperties.collection = self.collections[project.GlobalId] = self.project["blender"]

def create_collections(self):
self.create_spatial_decomposition_collections()
Expand Down

5 comments on commit 2557580

@Moult
Copy link
Contributor

@Moult Moult commented on 2557580 Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is actually allowed I.e. regular walls and elements cannot be aggregated to the IfcProject directly.

@Andrej730
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? It's not producing validation errors. Here's the example file:
elements_aggregated_by_ifcproject.ifc.txt

@aothms
Copy link
Member

@aothms aothms commented on 2557580 Nov 16, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andrej730
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aothms Found it, thank you, makes sense.
image

But shouldn't there be some kind of express validation rule for IfcRelAggregates that if RelatingObject is IfcProject then RelatedObjects cannot have IfcElements or something?

@aothms
Copy link
Member

@aothms aothms commented on 2557580 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Express is likely not the right place, but i've added a proposal here buildingSMART/ifc-gherkin-rules#111

Please sign in to comment.