mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Fix bug where an added default material was not linked and auto synced.
This commit is contained in:
@@ -101,7 +101,7 @@ class TestGetObject(test.bim.bootstrap.NewFile):
|
||||
|
||||
|
||||
class TestLink(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
def test_link_an_object(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
@@ -110,9 +110,18 @@ class TestLink(test.bim.bootstrap.NewFile):
|
||||
assert subject.get_entity(obj) == element
|
||||
assert subject.get_object(element) == obj
|
||||
|
||||
def test_link_a_material(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcMaterial()
|
||||
obj = bpy.data.materials.new("Material")
|
||||
subject.link(element, obj)
|
||||
assert subject.get_entity(obj) == element
|
||||
assert subject.get_object(element) == obj
|
||||
|
||||
|
||||
class TestUnlink(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
def test_unlink_an_object(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
@@ -122,6 +131,16 @@ class TestUnlink(test.bim.bootstrap.NewFile):
|
||||
assert subject.get_entity(obj) is None
|
||||
assert subject.get_object(element) is None
|
||||
|
||||
def test_unlink_a_material(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcMaterial()
|
||||
obj = bpy.data.materials.new("Material")
|
||||
subject.link(element, obj)
|
||||
subject.unlink(element, obj)
|
||||
assert subject.get_entity(obj) is None
|
||||
assert subject.get_object(element) is None
|
||||
|
||||
def test_unlinking_using_an_object(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
|
||||
@@ -34,22 +34,3 @@ class TestAddDefaultMaterialObject(NewFile):
|
||||
material = subject.add_default_material_object()
|
||||
assert isinstance(material, bpy.types.Material)
|
||||
assert material.name == "Default"
|
||||
|
||||
|
||||
class TestLink(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
ifc = ifcopenshell.file()
|
||||
material = ifc.createIfcMaterial()
|
||||
subject.link(material, obj)
|
||||
assert obj.BIMObjectProperties.ifc_definition_id == material.id()
|
||||
|
||||
|
||||
class TestUnlink(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
ifc = ifcopenshell.file()
|
||||
material = ifc.createIfcMaterial()
|
||||
subject.link(material, obj)
|
||||
subject.unlink(obj)
|
||||
assert obj.BIMObjectProperties.ifc_definition_id == 0
|
||||
|
||||
Reference in New Issue
Block a user