Arch - IFC : Handle case where NominalValue is None

This commit is contained in:
Jonathan Wiedemann 2016-02-25 11:23:10 +01:00
parent a3209e1aee
commit 604fc320cf

View File

@ -631,14 +631,15 @@ def insert(filename,docname,skip=[],only=[],root=None):
for p in properties[pid][c]: for p in properties[pid][c]:
l = ifcfile[p] l = ifcfile[p]
if l.is_a("IfcPropertySingleValue"): if l.is_a("IfcPropertySingleValue"):
if IMPORT_PROPERTIES : if DEBUG :
print("property name",l.Name,type(l.Name))
ifc_spreadsheet.set(str('A'+str(n)), catname.encode("utf8"))
ifc_spreadsheet.set(str('B'+str(n)), l.Name.encode("utf8"))
if l.NominalValue :
if DEBUG : if DEBUG :
print("property name",l.Name,type(l.Name))
print("property NominalValue",l.NominalValue.is_a(),type(l.NominalValue.is_a())) print("property NominalValue",l.NominalValue.is_a(),type(l.NominalValue.is_a()))
print("property NominalValue.wrappedValue",l.NominalValue.wrappedValue,type(l.NominalValue.wrappedValue)) print("property NominalValue.wrappedValue",l.NominalValue.wrappedValue,type(l.NominalValue.wrappedValue))
#print("l.NominalValue.Unit",l.NominalValue.Unit,type(l.NominalValue.Unit)) #print("l.NominalValue.Unit",l.NominalValue.Unit,type(l.NominalValue.Unit))
ifc_spreadsheet.set(str('A'+str(n)), catname.encode("utf8"))
ifc_spreadsheet.set(str('B'+str(n)), l.Name.encode("utf8"))
ifc_spreadsheet.set(str('C'+str(n)), l.NominalValue.is_a()) ifc_spreadsheet.set(str('C'+str(n)), l.NominalValue.is_a())
if l.NominalValue.is_a() in ['IfcLabel','IfcText','IfcIdentifier','IfcDescriptiveMeasure']: if l.NominalValue.is_a() in ['IfcLabel','IfcText','IfcIdentifier','IfcDescriptiveMeasure']:
ifc_spreadsheet.set(str('D'+str(n)), "'" + str(l.NominalValue.wrappedValue.encode("utf8"))) ifc_spreadsheet.set(str('D'+str(n)), "'" + str(l.NominalValue.wrappedValue.encode("utf8")))
@ -646,7 +647,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
ifc_spreadsheet.set(str('D'+str(n)), str(l.NominalValue.wrappedValue)) ifc_spreadsheet.set(str('D'+str(n)), str(l.NominalValue.wrappedValue))
if hasattr(l.NominalValue,'Unit') : if hasattr(l.NominalValue,'Unit') :
ifc_spreadsheet.set(str('E'+str(n)), str(l.NominalValue.Unit)) ifc_spreadsheet.set(str('E'+str(n)), str(l.NominalValue.Unit))
n += 1 n += 1
obj.IfcProperties = ifc_spreadsheet obj.IfcProperties = ifc_spreadsheet
elif hasattr(obj,"IfcAttributes"): elif hasattr(obj,"IfcAttributes"):
a = obj.IfcAttributes a = obj.IfcAttributes