Arch: Allow to write IFC objects without owner history (#13076)
* Arch: Allow to write IFC objects without owner history * Arch: Fixed context detection in IFC exporter
This commit is contained in:
@@ -265,7 +265,12 @@ def export(exportList, filename, colors=None, preferences=None):
|
||||
ifcfile = ifcopenshell.open(templatefile)
|
||||
ifcfile = exportIFCHelper.writeUnits(ifcfile,preferences["IFC_UNIT"])
|
||||
|
||||
history = ifcfile.by_type("IfcOwnerHistory")[0]
|
||||
history = ifcfile.by_type("IfcOwnerHistory")
|
||||
if history:
|
||||
history = history[0]
|
||||
else:
|
||||
# IFC4 allows to not write any history
|
||||
history = None
|
||||
objectslist = Draft.get_group_contents(exportList, walls=True,
|
||||
addgroups=True)
|
||||
|
||||
@@ -296,7 +301,9 @@ def export(exportList, filename, colors=None, preferences=None):
|
||||
|
||||
if existing_file:
|
||||
project = ifcfile.by_type("IfcProject")[0]
|
||||
context = ifcfile.by_type("IFcGeometricRepresentationContext")[-1]
|
||||
body_contexts = [c for c in ifcfile.by_type("IfcGeometricRepresentationSubContext") if c.ContextIdentifier in ["Body", "Facetation"]]
|
||||
body_contexts.extend([c for c in ifcfile.by_type("IfcGeometricRepresentationContext", include_subtypes=False) if c.ContextType == "Model"])
|
||||
context = body_contexts[0] # we take the first one (subcontext if existing, or context if not)
|
||||
else:
|
||||
contextCreator = exportIFCHelper.ContextCreator(ifcfile, objectslist)
|
||||
context = contextCreator.model_view_subcontext
|
||||
|
||||
Reference in New Issue
Block a user