Prevent adding name callback to non-ifc blender materials

Also removing one more artifact from #4843
This commit is contained in:
Andrej730
2024-10-22 18:19:22 +05:00
parent b7dfeaee37
commit 863633f2dc
2 changed files with 6 additions and 12 deletions
+5 -7
View File
@@ -96,7 +96,7 @@ class Ifc(bonsai.core.tool.Ifc):
@classmethod
def get_entity(cls, obj: IFC_CONNECTED_TYPE) -> Union[ifcopenshell.entity_instance, None]:
"""Get linked IFC entity based on obj's BIMObjectProperties.ifc_definition_id.
"""Get linked IFC entity based on obj's ifc_definition_id.
Return None if object is not linked to IFC or it's linked to non-existent element.
"""
@@ -172,13 +172,11 @@ class Ifc(bonsai.core.tool.Ifc):
bpy.msgbus.clear_by_owner(obj)
material = cls.get_entity(obj)
style = tool.Style.get_style(obj)
if material:
IfcStore.id_map[material.id()] = obj
if style:
IfcStore.id_map[style.id()] = obj
style = cls.get_entity(obj)
if not style:
continue
IfcStore.id_map[style.id()] = obj
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
@classmethod
+1 -5
View File
@@ -149,11 +149,7 @@ class Style(bonsai.core.tool.Style):
Return None if material is not linked to IFC or it's linked to non-existent element.
"""
if ifc_definition_id := obj.BIMStyleProperties.ifc_definition_id:
try:
return tool.Ifc.get().by_id(ifc_definition_id)
except:
return
return tool.Ifc.get_entity(obj)
@classmethod
def get_style_elements(