Removing drawings now roundtrips in IFC. See #1153.

This commit is contained in:
Dion Moult
2022-02-04 10:54:18 +11:00
parent 868ced2990
commit 7116a9f71a
6 changed files with 110 additions and 9 deletions
+58
View File
@@ -24,6 +24,7 @@ import blenderbim.core.tool
import blenderbim.tool as tool
from test.bim.bootstrap import NewFile
from blenderbim.tool.drawing import Drawing as subject
from blenderbim.bim.ifc import IfcStore
class TestImplementsTool(NewFile):
@@ -50,6 +51,30 @@ class TestCreateSvgSheet(NewFile):
assert os.path.isfile(os.path.join(bpy.context.scene.BIMProperties.data_dir, "sheets", "X - FOOBAR.svg"))
class TestDeleteCollection(NewFile):
def test_run(self):
collection = bpy.data.collections.new("Foobar")
subject.delete_collection(collection)
assert not bpy.data.collections.get("Foobar")
class TestDeleteDrawingElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
obj = bpy.data.objects.new("Object", None)
collection = bpy.data.collections.new("Collection")
bpy.context.scene.collection.children.link(collection)
collection.objects.link(obj)
element = ifc.createIfcAnnotation()
tool.Ifc.link(element, obj)
element_id = element.id()
subject.delete_drawing_elements([element])
assert element_id in IfcStore.deleted_ids
assert not bpy.data.objects.get("Object")
class TestDisableEditingDrawings(NewFile):
def test_run(self):
bpy.context.scene.DocProperties.is_editing_drawings = True
@@ -159,6 +184,39 @@ class TestGetBodyContext(NewFile):
assert subject.get_body_context() == context
class TestGetDrawingCollection(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
obj = bpy.data.objects.new("Object", None)
collection = bpy.data.collections.new("Collection")
bpy.context.scene.collection.children.link(collection)
collection.objects.link(obj)
element = ifc.createIfcAnnotation()
tool.Ifc.link(element, obj)
assert subject.get_drawing_collection(element) == collection
class TestGetDrawingGroup(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifc.createIfcAnnotation()
group = ifcopenshell.api.run("group.add_group", ifc)
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
assert subject.get_drawing_group(element) == group
class TestGetGroupElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifc.createIfcAnnotation()
group = ifcopenshell.api.run("group.add_group", ifc)
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
assert subject.get_group_elements(group) == (element,)
class TestGetSheetFilename(NewFile):
def test_run(self):
ifc = ifcopenshell.file()