Fix bugs where adding types without a material was broken. See #1513.

This commit is contained in:
Dion Moult
2021-06-06 09:57:50 +10:00
parent e0cbbf2eb7
commit a8dc734351
4 changed files with 5 additions and 2 deletions
@@ -6,6 +6,7 @@ import ifcopenshell.util.representation
from . import wall, slab
from blenderbim.bim.ifc import IfcStore
from ifcopenshell.api.pset.data import Data as PsetData
from mathutils import Vector
class AddTypeInstance(bpy.types.Operator):
@@ -150,7 +150,7 @@ class DumbSlabPlaner:
def regenerate_from_type(self, usecase_path, ifc_file, settings):
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
new_material = ifcopenshell.util.element.get_material(settings["relating_type"])
if not new_material.is_a("IfcMaterialLayerSet"):
if not new_material or not new_material.is_a("IfcMaterialLayerSet"):
return
new_thickness = sum([l.LayerThickness for l in new_material.MaterialLayers])
self.change_thickness(settings["related_object"], new_thickness)
@@ -819,7 +819,7 @@ class DumbWallPlaner:
def regenerate_from_type(self, usecase_path, ifc_file, settings):
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
new_material = ifcopenshell.util.element.get_material(settings["relating_type"])
if not new_material.is_a("IfcMaterialLayerSet"):
if not new_material or not new_material.is_a("IfcMaterialLayerSet"):
return
new_thickness = sum([l.LayerThickness for l in new_material.MaterialLayers])
self.change_thickness(settings["related_object"], new_thickness)
@@ -84,6 +84,8 @@ class Usecase:
def map_material_usages(self):
type_material = ifcopenshell.util.element.get_material(self.settings["relating_type"])
if not type_material:
return
if type_material.is_a("IfcMaterialLayerSet"):
ifcopenshell.api.run(
"material.assign_material",