[Arch] export IFC: assign space to storey as aggregation

According to the standard, entities of type IfcSpatialStructureElement
should not be related to other spatial structure elements through
IfcRelContainedInSpatialStructure but through IfcRelAggregates.
This commit is contained in:
hlg
2019-12-06 14:15:46 +01:00
committed by Yorik van Havre
parent 4a6d68f35d
commit fff55c7ae5

View File

@@ -802,23 +802,35 @@ def export(exportList,filename,colors=None,preferences=None):
if (Draft.getType(floor) == "Floor") or (hasattr(floor,"IfcType") and floor.IfcType == "Building Storey"):
objs = Draft.getGroupContents(floor,walls=True,addgroups=True)
objs = Arch.pruneIncluded(objs)
children = []
objs.remove(floor) # getGroupContents + addgroups will include the floor itself
buildingelements, spaces = [], []
for c in objs:
if c.Name != floor.Name: # getGroupContents + addgroups will include the floor itself
if c.Name in products.keys():
if not (c.Name in treated):
children.append(products[c.Name])
treated.append(c.Name)
if c.Name in products and c.Name not in treated:
prod = products[c.Name]
if prod.is_a()=='IfcSpace':
spaces.append(prod)
else:
buildingelements.append(prod)
treated.append(c.Name)
f = products[floor.Name]
if children:
if buildingelements:
ifcfile.createIfcRelContainedInSpatialStructure(
ifcopenshell.guid.new(),
history,
'StoreyLink',
'',
children,
buildingelements,
f
)
if spaces:
ifcfile.createIfcRelAggregates(
ifcopenshell.guid.new(),
history,
'StoreyLink',
'',
f,
spaces
)
floors.append(f)
defaulthost = f
@@ -834,7 +846,7 @@ def export(exportList,filename,colors=None,preferences=None):
if not (c.Name in treated):
if c.Name != building.Name: # getGroupContents + addgroups will include the building itself
if c.Name in products.keys():
if Draft.getType(c) in ["Floor","BuildingPart"]:
if Draft.getType(c) in ["Floor","BuildingPart","Space"]:
childfloors.append(products[c.Name])
treated.append(c.Name)
elif not (c.Name in treated):
@@ -1022,13 +1034,29 @@ def export(exportList,filename,colors=None,preferences=None):
elif buildings:
defaulthost = buildings[0]
if defaulthost:
ifcfile.createIfcRelContainedInSpatialStructure(
ifcopenshell.guid.new(),
history,
'UnassignedObjectsLink',
'',
untreated,
defaulthost
spaces, buildingelements = [],[]
for entity in untreated:
if entity.is_a()=="IfcSpace":
spaces.append(entity)
else:
buildingelements.append(entity)
if spaces:
ifcfile.createIfcRelAggregates(
ifcopenshell.guid.new(),
history,
'UnassignedObjectsLink',
'',
defaulthost,
spaces
)
if buildingelements:
ifcfile.createIfcRelContainedInSpatialStructure(
ifcopenshell.guid.new(),
history,
'UnassignedObjectsLink',
'',
buildingelements,
defaulthost
)
else:
# no default host: aggregate unassigned objects directly under the IfcProject - WARNING: NON STANDARD