Skip to content

Commit

Permalink
Arch: ifc import, move getting the property relation table in separat…
Browse files Browse the repository at this point in the history
…e method
  • Loading branch information
berndhahnebach committed Jul 24, 2019
1 parent e1cb4f2 commit 96b7402
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -342,13 +342,13 @@ def insert(filename,docname,skip=[],only=[],root=None):
if DEBUG: print("Building relationships table...",end="")

# building relations tables
# TODO use inverse attributes, see https://forum.freecadweb.org/viewtopic.php?f=39&t=37892

objects = {} # { id:object, ... }
prodrepr = {} # product/representations table
additions = {} # { host:[child,...], ... }
groups = {} # { host:[child,...], ... } # used in structural IFC
subtractions = [] # [ [opening,host], ... ]
properties = {} # { objid : { psetid : [propertyid, ... ], ... }, ... }
colors = {} # { id:(r,g,b) }
shapes = {} # { id:shaoe } only used for merge mode
structshapes = {} # { id:shaoe } only used for merge mode
Expand All @@ -365,16 +365,8 @@ def insert(filename,docname,skip=[],only=[],root=None):
groups.setdefault(r.RelatingGroup.id(),[]).extend([e.id() for e in r.RelatedObjects])
for r in ifcfile.by_type("IfcRelVoidsElement"):
subtractions.append([r.RelatedOpeningElement.id(), r.RelatingBuildingElement.id()])
for r in ifcfile.by_type("IfcRelDefinesByProperties"):
for obj in r.RelatedObjects:
if not obj.id() in properties:
properties[obj.id()] = {}
psets = {}
props = []
if r.RelatingPropertyDefinition.is_a("IfcPropertySet"):
props.extend([prop.id() for prop in r.RelatingPropertyDefinition.HasProperties])
psets[r.RelatingPropertyDefinition.id()] = props
properties[obj.id()].update(psets)
# properties = {} # { objid : { psetid : [propertyid, ... ], ... }, ... }
properties = getRelProperties(ifcfile)
for r in ifcfile.by_type("IfcRelAssociatesMaterial"):
for o in r.RelatedObjects:
if r.RelatingMaterial.is_a("IfcMaterial"):
Expand Down Expand Up @@ -1251,6 +1243,22 @@ def insert(filename,docname,skip=[],only=[],root=None):
# ************************************************************************************************
# ********** helper for import IFC **************

def getRelProperties(ifcfile):

properties = {} # { objid : { psetid : [propertyid, ... ], ... }, ... }
for r in ifcfile.by_type("IfcRelDefinesByProperties"):
for obj in r.RelatedObjects:
if not obj.id() in properties:
properties[obj.id()] = {}
psets = {}
props = []
if r.RelatingPropertyDefinition.is_a("IfcPropertySet"):
props.extend([prop.id() for prop in r.RelatingPropertyDefinition.HasProperties])
psets[r.RelatingPropertyDefinition.id()] = props
properties[obj.id()].update(psets)
return properties


def getIfcProperties(ifcfile, pid, properties, d):

for pset in properties[pid].keys():
Expand Down

0 comments on commit 96b7402

Please sign in to comment.