mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Fix #2046. Fix crash if style was updated from an already loaded IFC dataset
This commit is contained in:
@@ -37,7 +37,7 @@ class Usecase:
|
|||||||
to_delete.add(texture)
|
to_delete.add(texture)
|
||||||
|
|
||||||
for attribute in self.settings["style"]:
|
for attribute in self.settings["style"]:
|
||||||
if isinstance(attribute, ifcopenshell.entity_instance):
|
if isinstance(attribute, ifcopenshell.entity_instance) and attribute.id():
|
||||||
to_delete.add(attribute)
|
to_delete.add(attribute)
|
||||||
|
|
||||||
self.file.remove(self.settings["style"])
|
self.file.remove(self.settings["style"])
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import ifcopenshell.api
|
|||||||
|
|
||||||
class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
||||||
def test_removing_a_shading_style(self):
|
def test_removing_a_shading_style(self):
|
||||||
style = self.file.createIfcSurfaceStyleShading(SurfaceColour=self.file.createIfcColourRgb())
|
style = self.file.createIfcSurfaceStyleShading(SurfaceColour=self.file.createIfcColourRgb(None, 1, 1, 1))
|
||||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||||
assert len(list(self.file)) == 0
|
assert len(list(self.file)) == 0
|
||||||
|
|
||||||
@@ -39,3 +39,19 @@ class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
|||||||
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
|
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
|
||||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||||
assert len(list(self.file)) == 0
|
assert len(list(self.file)) == 0
|
||||||
|
|
||||||
|
def test_removing_a_rendering_style(self):
|
||||||
|
style = self.file.createIfcSurfaceStyleRendering(
|
||||||
|
SurfaceColour=self.file.createIfcColourRgb(None, 1, 1, 1),
|
||||||
|
Transparency=0.0,
|
||||||
|
DiffuseColour=self.file.createIfcColourRgb(None, 1, 1, 1),
|
||||||
|
TransmissionColour=self.file.createIfcNormalisedRatioMeasure(0.5),
|
||||||
|
SpecularHighlight=self.file.createIfcSpecularRoughness(0.5),
|
||||||
|
ReflectanceMethod="NOTDEFINED",
|
||||||
|
)
|
||||||
|
# See issue #2046, IfcOpenShell exhibits different behaviour - we can
|
||||||
|
# remove entity_instances() without an ID if we create them afresh, but
|
||||||
|
# will segfault if we load them stale.
|
||||||
|
g = ifcopenshell.file.from_string(self.file.wrapped_data.to_string())
|
||||||
|
ifcopenshell.api.run("style.remove_surface_style", g, style=g.by_type("IfcSurfaceStyleRendering")[0])
|
||||||
|
assert len(list(g)) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user