mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Fix errors in tests and scripts removing styles
remove_style relies on style_type which is using StylesData to get the enum of it's values and StylesData will fail to load on `material = tool.Ifc.get_object(ifc_file.by_id(style.ifc_definition_id))` as ifc_definition_id was removed but not yet removed as an item from styles ui. This issue doesn't occur when user is working from UI since StylesData precached when they load styles UI but if they run a script (as we do in bim tests) StylesData is not precached and will be loaded when get_active_style_type() is called leading to errors.
This commit is contained in:
@@ -57,11 +57,14 @@ def update_external_style(
|
||||
|
||||
def remove_style(ifc: tool.Ifc, style_tool: tool.Style, style: ifcopenshell.entity_instance) -> None:
|
||||
obj = ifc.get_object(style)
|
||||
# Get style_type before removing object as later StylesData might fail to load
|
||||
# due object not yet removed completely.
|
||||
style_type = style_tool.get_active_style_type()
|
||||
ifc.unlink(element=style)
|
||||
ifc.run("style.remove_style", style=style)
|
||||
style_tool.delete_object(obj)
|
||||
if style_tool.is_editing_styles():
|
||||
style_tool.import_presentation_styles(style_tool.get_active_style_type())
|
||||
style_tool.import_presentation_styles(style_type)
|
||||
|
||||
|
||||
def update_style_colours(ifc: tool.Ifc, style: tool.Style, obj: bpy.types.Material, verbose: bool = False) -> None:
|
||||
|
||||
Reference in New Issue
Block a user