Files
IfcOpenShell/src/ifcblenderexport/blenderbim/bim/module/context/data.py
T

31 lines
1.0 KiB
Python

import blenderbim.bim.ifc
is_loaded = False
class Data:
is_loaded = False
contexts = {}
@classmethod
def load(cls):
file = blenderbim.bim.ifc.IfcStore.get_file()
if not file:
return
cls.contexts = {}
for context in file.by_type("IfcGeometricRepresentationContext", include_subtypes=False):
subcontexts = {}
# See bug #1224 for why we don't use HasSubContexts
for subcontext in file.by_type("IfcGeometricRepresentationSubContext"):
if subcontext.ParentContext != context:
continue
subcontexts[int(subcontext.id())] = {
"ContextType": subcontext.ContextType,
"ContextIdentifier": subcontext.ContextIdentifier,
"TargetView": subcontext.TargetView,
}
cls.contexts[int(context.id())] = {
"ContextType": context.ContextType,
"HasSubContexts": subcontexts
}
cls.is_loaded = True