Minor fix for IFC2X3

This commit is contained in:
Dion Moult
2020-05-09 12:47:26 +10:00
parent c83af5fc2a
commit 752a7c9b1c
4 changed files with 12 additions and 14 deletions
@@ -640,7 +640,11 @@ class IfcParser():
def get_classification_reference_maps(self):
results = {}
for filename, classification in self.classifications.items():
results[filename] = { e.Identification: e for e in schema.ifc.classification_files[filename].by_type('IfcClassificationReference')}
ifc_file = schema.ifc.classification_files[filename]
if ifc_file.schema == 'IFC2X3':
results[filename] = { e.ItemReference: e for e in ifc_file.by_type('IfcClassificationReference')}
else:
results[filename] = { e.Identification: e for e in ifc_file.by_type('IfcClassificationReference')}
return results
def get_classification_references(self):
@@ -1104,9 +1108,10 @@ class IfcExporter():
self.ifc_export_settings = ifc_export_settings
self.ifc_parser = ifc_parser
self.qto_calculator = qto_calculator
self.schema = 'IFC4'
def export(self, selected_objects):
self.file = ifcopenshell.open(self.template_file)
self.file = ifcopenshell.file(schema=self.schema)
self.ifc_parser.parse(selected_objects)
self.create_units()
self.create_people()
@@ -2530,6 +2530,8 @@ class PushRepresentation(bpy.types.Operator):
# Warning: This is an incredibly experimental operator.
def execute(self, context):
self.file = ifc.IfcStore.get_file()
logger = logging.getLogger('ExportIFC')
output_file = 'tmp.ifc'
ifc_export_settings = export_ifc.IfcExportSettings.factory(context, output_file, logger)
@@ -2537,13 +2539,12 @@ class PushRepresentation(bpy.types.Operator):
ifc_parser.parse([bpy.context.active_object])
qto_calculator = export_ifc.QtoCalculator()
self.ifc_exporter = export_ifc.IfcExporter(ifc_export_settings, ifc_parser, qto_calculator)
self.ifc_exporter.file = ifcopenshell.open(self.ifc_exporter.template_file)
self.ifc_exporter.file = ifcopenshell.file(schema=self.file.schema)
self.ifc_exporter.create_origin()
self.ifc_exporter.create_rep_context()
self.ifc_exporter.create_representations()
self.context, self.subcontext, self.target_view, self.mesh_name = bpy.context.active_object.data.name.split('/')
self.file = ifc.IfcStore.get_file()
rep_context = self.get_geometric_representation_context()
for key, rep in self.ifc_exporter.ifc_parser.representations.items():
@@ -74,7 +74,8 @@ class IfcSchema():
def get_classification_references(self, classification):
references = {}
if not classification.HasReferences:
if not hasattr(classification, 'HasReferences') \
or not classification.HasReferences:
return references
for reference in classification.HasReferences:
references[reference.Identification] = {
@@ -1,9 +0,0 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
FILE_NAME('$filename','2019-05-12T12:33:45',('$owner','$email'),('$company'),'IfcOpenShell','IfcOpenShell','');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
ENDSEC;
END-ISO-10303-21;