From 240b642d6d96bbc1b0ad55ed483f2fc952fe4ea9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 17 Oct 2019 18:46:06 +1100 Subject: [PATCH 1/2] Test light schedule data for gbxml --- src/ifcblenderexport/gbxml.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/gbxml.py b/src/ifcblenderexport/gbxml.py index 3fcf3ccc8c..9e919dd031 100644 --- a/src/ifcblenderexport/gbxml.py +++ b/src/ifcblenderexport/gbxml.py @@ -2,6 +2,7 @@ import bpy import uuid import math import sys +import lxml #sys.path.append('C:\Program Files\Python37\Lib\site-packages') import bspy from bspy import Gbxml @@ -53,13 +54,22 @@ class GbxmlExporter(): r_value = self.gbxml.add_element(material, 'R-value', '0.13') r_value.set('unit', 'SquareMeterKPerW') - self.gbxml.write('C:/cygwin64/home/moud308/Projects/New Folder/out.xml') + parser = lxml.etree.XMLParser(remove_blank_text=True) + template = lxml.etree.parse('C:/cygwin64/home/moud308/Projects/New Folder/presets/light-schedule.xml', parser).findall('.')[0] + for child in template.getchildren(): + self.gbxml.root().append(child) + + with open('C:/cygwin64/home/moud308/Projects/New Folder/out.xml', 'w') as out: + out.write(self.gbxml.xmlstring()) print('# Validation results: {}'.format(self.gbxml.validate())) print('# Finish export') def create_space(self, object, building): space = self.gbxml.add_element(building, 'Space') space.set('id', object.name) + space.set('lightScheduleIdRef', 'aim0130') # hardcoded + light_power_per_area = self.gbxml.add_element(space, 'LightPowerPerArea', '5') # hardcoded test + light_power_per_area.set('unit', 'WattPerSquareMeter') calculated_area = 0 shell_geometry = self.gbxml.add_element(space, 'ShellGeometry') From 791be5006b8abf6c253c7d7130974523e5c88220 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 17 Oct 2019 18:47:01 +1100 Subject: [PATCH 2/2] Couple of minor fixes to make importing more robust --- src/ifcblenderexport/io_export_ifc/import_ifc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ifcblenderexport/io_export_ifc/import_ifc.py b/src/ifcblenderexport/io_export_ifc/import_ifc.py index 10413283f8..994bba95b9 100644 --- a/src/ifcblenderexport/io_export_ifc/import_ifc.py +++ b/src/ifcblenderexport/io_export_ifc/import_ifc.py @@ -110,7 +110,11 @@ class IfcImporter(): if element.is_a('IfcOpeningElement'): return - shape = ifcopenshell.geom.create_shape(self.settings, element) + try: + shape = ifcopenshell.geom.create_shape(self.settings, element) + except: + print('Failed to generate shape for {}'.format(element)) + return mesh_name = 'mesh-{}'.format(shape.geometry.id) mesh = self.meshes.get(mesh_name) @@ -135,7 +139,8 @@ class IfcImporter(): matrix.transpose() object.matrix_world = matrix - if element.ContainedInStructure \ + if hasattr(element, 'ContainedInStructure') \ + and element.ContainedInStructure \ and element.ContainedInStructure[0].RelatingStructure: structure_name = self.get_name(element.ContainedInStructure[0].RelatingStructure) if structure_name in self.spatial_structure_elements: