Fix bug where unlinking a style that was invalidly linked didn't work.

This commit is contained in:
Dion Moult
2021-11-16 22:08:55 +11:00
parent edd01637e2
commit 468192e849
2 changed files with 9 additions and 1 deletions
+4 -1
View File
@@ -46,7 +46,10 @@ class Style(blenderbim.core.tool.Style):
@classmethod
def get_style(cls, obj):
if obj.BIMMaterialProperties.ifc_style_id:
return tool.Ifc.get().by_id(obj.BIMMaterialProperties.ifc_style_id)
try:
return tool.Ifc.get().by_id(obj.BIMMaterialProperties.ifc_style_id)
except:
return
@classmethod
def get_surface_rendering_attributes(cls, obj):
+5
View File
@@ -74,6 +74,11 @@ class TestGetStyle(NewFile):
obj.BIMMaterialProperties.ifc_style_id = style.id()
assert subject.get_style(obj) == style
def test_getting_nothing_for_a_broken_link_style(self):
obj = bpy.data.materials.new("Material")
obj.BIMMaterialProperties.ifc_style_id = 1
assert subject.get_style(obj) == None
class TestGetSurfaceRenderingAttributes(NewFile):
def test_get_colours_from_a_basic_material(self):