Merge branch 'v0.6.0' of github.com:IfcOpenShell/IfcOpenShell into v0.6.0

This commit is contained in:
Dion Moult
2019-10-19 10:47:15 +11:00
2 changed files with 18 additions and 3 deletions
+11 -1
View File
@@ -2,6 +2,7 @@ import bpy
import uuid import uuid
import math import math
import sys import sys
import lxml
#sys.path.append('C:\Program Files\Python37\Lib\site-packages') #sys.path.append('C:\Program Files\Python37\Lib\site-packages')
import bspy import bspy
from bspy import Gbxml from bspy import Gbxml
@@ -53,13 +54,22 @@ class GbxmlExporter():
r_value = self.gbxml.add_element(material, 'R-value', '0.13') r_value = self.gbxml.add_element(material, 'R-value', '0.13')
r_value.set('unit', 'SquareMeterKPerW') 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('# Validation results: {}'.format(self.gbxml.validate()))
print('# Finish export') print('# Finish export')
def create_space(self, object, building): def create_space(self, object, building):
space = self.gbxml.add_element(building, 'Space') space = self.gbxml.add_element(building, 'Space')
space.set('id', object.name) 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 calculated_area = 0
shell_geometry = self.gbxml.add_element(space, 'ShellGeometry') shell_geometry = self.gbxml.add_element(space, 'ShellGeometry')
@@ -110,7 +110,11 @@ class IfcImporter():
if element.is_a('IfcOpeningElement'): if element.is_a('IfcOpeningElement'):
return 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_name = 'mesh-{}'.format(shape.geometry.id)
mesh = self.meshes.get(mesh_name) mesh = self.meshes.get(mesh_name)
@@ -135,7 +139,8 @@ class IfcImporter():
matrix.transpose() matrix.transpose()
object.matrix_world = matrix object.matrix_world = matrix
if element.ContainedInStructure \ if hasattr(element, 'ContainedInStructure') \
and element.ContainedInStructure \
and element.ContainedInStructure[0].RelatingStructure: and element.ContainedInStructure[0].RelatingStructure:
structure_name = self.get_name(element.ContainedInStructure[0].RelatingStructure) structure_name = self.get_name(element.ContainedInStructure[0].RelatingStructure)
if structure_name in self.spatial_structure_elements: if structure_name in self.spatial_structure_elements: