Skip to content

Commit

Permalink
[Arch] export IFC: assign space to storey as aggregation
Browse files Browse the repository at this point in the history
According to the standard, entities of type IfcSpatialStructureElement
should not be related to other spatial structure elements through
IfcRelContainedInSpatialStructure but through IfcRelAggregates.
  • Loading branch information
hlg authored and yorikvanhavre committed Dec 17, 2019
1 parent 4a6d68f commit fff55c7
Showing 1 changed file with 44 additions and 16 deletions.
60 changes: 44 additions & 16 deletions src/Mod/Arch/exportIFC.py
Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fff55c7

Please sign in to comment.