Skip to content

Commit a8f1a28

Browse files
committed
fix replacing material with material profile
1 parent d2f4f0d commit a8f1a28

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/blenderbim/blenderbim/tool/material.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ def is_a_flow_segment(cls, element):
212212
def replace_material_with_material_profile(cls, element):
213213
old_material = cls.get_material(element, should_inherit=False)
214214
old_inherited_material = cls.get_material(element, should_inherit=True)
215-
blenderbim.core.material.unassign_material(tool.Ifc, tool.Material, objects=[tool.Ifc.get_object(element)])
216-
tool.Ifc.run("material.assign_material", product=element, type="IfcMaterialProfileSet")
217-
assinged_material = cls.get_material(element)
218215
material = old_material if old_material and old_material.is_a("IfcMaterial") else None
219216
if not material and old_inherited_material:
220217
material = old_inherited_material if old_inherited_material.is_a("IfcMaterial") else None
218+
if not material:
219+
material = tool.Ifc.get().by_type("IfcMaterial")[0]
220+
else:
221+
blenderbim.core.material.unassign_material(tool.Ifc, tool.Material, objects=[tool.Ifc.get_object(element)])
222+
tool.Ifc.run("material.assign_material", product=element, type="IfcMaterialProfileSet", material=material)
223+
assinged_material = cls.get_material(element)
221224
material_profile = tool.Ifc.run("material.add_profile", profile_set=assinged_material, material=material)
222225
return material_profile

0 commit comments

Comments
 (0)