mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Fix crash during test_remove_fill_area_with_fill_area_style_hatching
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import ifcopenshell.api.style
|
import ifcopenshell.api.style
|
||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
from typing import Any
|
from typing import Iterable
|
||||||
|
|
||||||
|
|
||||||
def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -> None:
|
def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -> None:
|
||||||
@@ -47,9 +47,10 @@ def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -
|
|||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
file: ifcopenshell.file
|
file: ifcopenshell.file
|
||||||
settings: dict[str, Any]
|
|
||||||
|
|
||||||
def execute(self, style: ifcopenshell.entity_instance) -> None:
|
def execute(
|
||||||
|
self, style: ifcopenshell.entity_instance, do_not_delete: Iterable[ifcopenshell.entity_instance] = ()
|
||||||
|
) -> None:
|
||||||
self.purge_inverses(style)
|
self.purge_inverses(style)
|
||||||
ifc_class = style.is_a()
|
ifc_class = style.is_a()
|
||||||
if ifc_class == "IfcSurfaceStyle":
|
if ifc_class == "IfcSurfaceStyle":
|
||||||
@@ -57,7 +58,9 @@ class Usecase:
|
|||||||
ifcopenshell.api.style.remove_surface_style(self.file, style=style_)
|
ifcopenshell.api.style.remove_surface_style(self.file, style=style_)
|
||||||
elif ifc_class == "IfcFillAreaStyle":
|
elif ifc_class == "IfcFillAreaStyle":
|
||||||
for style_ in style.FillStyles:
|
for style_ in style.FillStyles:
|
||||||
ifcopenshell.util.element.remove_deep2(self.file, style_, also_consider=[style])
|
ifcopenshell.util.element.remove_deep2(
|
||||||
|
self.file, style_, also_consider=[style], do_not_delete=list(do_not_delete)
|
||||||
|
)
|
||||||
self.file.remove(style)
|
self.file.remove(style)
|
||||||
|
|
||||||
def purge_inverses(self, style: ifcopenshell.entity_instance) -> None:
|
def purge_inverses(self, style: ifcopenshell.entity_instance) -> None:
|
||||||
@@ -86,5 +89,5 @@ class Usecase:
|
|||||||
) -> None:
|
) -> None:
|
||||||
for inverse in self.file.get_inverse(fill_area_style_hatching):
|
for inverse in self.file.get_inverse(fill_area_style_hatching):
|
||||||
if inverse.is_a("IfcFillAreaStyle"):
|
if inverse.is_a("IfcFillAreaStyle"):
|
||||||
self.execute(inverse)
|
self.execute(inverse, do_not_delete=(fill_area_style_hatching, style))
|
||||||
ifcopenshell.util.element.remove_deep2(self.file, fill_area_style_hatching, do_not_delete=[style])
|
ifcopenshell.util.element.remove_deep2(self.file, fill_area_style_hatching, do_not_delete=[style])
|
||||||
|
|||||||
Reference in New Issue
Block a user