mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 19:27:10 +00:00
Fix bug where imported types with representations but no instances were not fully linked.
This commit is contained in:
@@ -527,6 +527,7 @@ class IfcImporter:
|
|||||||
try:
|
try:
|
||||||
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation)
|
shape = ifcopenshell.geom.create_shape(self.settings, representation_map.MappedRepresentation)
|
||||||
mesh = self.create_mesh(element, shape)
|
mesh = self.create_mesh(element, shape)
|
||||||
|
self.link_mesh(shape, mesh)
|
||||||
self.meshes[mesh_name] = mesh
|
self.meshes[mesh_name] = mesh
|
||||||
except:
|
except:
|
||||||
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
|
self.ifc_import_settings.logger.error("Failed to generate shape for %s", element)
|
||||||
@@ -729,10 +730,7 @@ class IfcImporter:
|
|||||||
mesh = self.meshes.get(mesh_name)
|
mesh = self.meshes.get(mesh_name)
|
||||||
if mesh is None:
|
if mesh is None:
|
||||||
mesh = self.create_mesh(element, shape)
|
mesh = self.create_mesh(element, shape)
|
||||||
if "-" in shape.geometry.id:
|
self.link_mesh(shape, mesh)
|
||||||
mesh.BIMMeshProperties.ifc_definition_id = int(shape.geometry.id.split("-")[0])
|
|
||||||
else:
|
|
||||||
mesh.BIMMeshProperties.ifc_definition_id = int(shape.geometry.id)
|
|
||||||
self.meshes[mesh_name] = mesh
|
self.meshes[mesh_name] = mesh
|
||||||
else:
|
else:
|
||||||
mesh = None
|
mesh = None
|
||||||
@@ -1422,6 +1420,16 @@ class IfcImporter:
|
|||||||
self.added_data[element.id()] = obj
|
self.added_data[element.id()] = obj
|
||||||
IfcStore.link_element(element, obj)
|
IfcStore.link_element(element, obj)
|
||||||
|
|
||||||
|
def link_mesh(self, shape, mesh):
|
||||||
|
if hasattr(shape, "geometry"):
|
||||||
|
geometry = shape.geometry
|
||||||
|
else:
|
||||||
|
geometry = shape
|
||||||
|
if "-" in geometry.id:
|
||||||
|
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id.split("-")[0])
|
||||||
|
else:
|
||||||
|
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id)
|
||||||
|
|
||||||
|
|
||||||
class IfcImportSettings:
|
class IfcImportSettings:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ Scenario: Load project elements - load all project elements
|
|||||||
And the object "IfcBeam/Beam" is in the collection "IfcElementAssembly/Empty"
|
And the object "IfcBeam/Beam" is in the collection "IfcElementAssembly/Empty"
|
||||||
And the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
|
And the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
|
||||||
And the object "IfcWall/Wall" is in the collection "IfcBuildingStorey/Level 1"
|
And the object "IfcWall/Wall" is in the collection "IfcBuildingStorey/Level 1"
|
||||||
|
And the object "IfcSlab/Slab" has data which is an IFC representation
|
||||||
|
And the object "IfcBeam/Beam" has data which is an IFC representation
|
||||||
|
And the object "IfcWall/Wall" has data which is an IFC representation
|
||||||
|
And the object "IfcSlabType/Slab" has data which is an IFC representation
|
||||||
|
And the object "IfcWallType/Wall" has data which is an IFC representation
|
||||||
And "scene.BIMProjectProperties.is_loading" is "False"
|
And "scene.BIMProjectProperties.is_loading" is "False"
|
||||||
|
|
||||||
Scenario: Load project elements - load objects filtered by decomposition
|
Scenario: Load project elements - load objects filtered by decomposition
|
||||||
|
|||||||
@@ -321,6 +321,12 @@ def the_object_name_is_not_an_ifc_element(name):
|
|||||||
assert id == 0, f"The ID is {id}"
|
assert id == 0, f"The ID is {id}"
|
||||||
|
|
||||||
|
|
||||||
|
@then(parsers.parse('the object "{name}" has data which is an IFC representation'))
|
||||||
|
def the_object_name_is_not_an_ifc_element(name):
|
||||||
|
id = the_object_name_exists(name).data.BIMMeshProperties.ifc_definition_id
|
||||||
|
assert id != 0, f"The ID is {id}"
|
||||||
|
|
||||||
|
|
||||||
@then(parsers.parse('the material "{name}" is not an IFC material'))
|
@then(parsers.parse('the material "{name}" is not an IFC material'))
|
||||||
def the_material_name_is_not_an_ifc_material(name):
|
def the_material_name_is_not_an_ifc_material(name):
|
||||||
id = the_material_name_exists(name).BIMObjectProperties.ifc_definition_id
|
id = the_material_name_exists(name).BIMObjectProperties.ifc_definition_id
|
||||||
|
|||||||
Reference in New Issue
Block a user