mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
You can now associate annotations with objects for smart annotations in IFC. See #1153.
This commit is contained in:
@@ -41,3 +41,27 @@ class TestEditText:
|
||||
drawing.update_text_value("obj").should_be_called()
|
||||
drawing.disable_editing_text("obj").should_be_called()
|
||||
subject.edit_text(ifc, drawing, obj="obj")
|
||||
|
||||
|
||||
class TestEnableEditingTextProduct:
|
||||
def test_run(self, drawing):
|
||||
drawing.enable_editing_text_product("obj").should_be_called()
|
||||
drawing.import_text_product("obj").should_be_called()
|
||||
subject.enable_editing_text_product(drawing, obj="obj")
|
||||
|
||||
|
||||
class TestDisableEditingTextProduct:
|
||||
def test_run(self, drawing):
|
||||
drawing.disable_editing_text_product("obj").should_be_called()
|
||||
subject.disable_editing_text_product(drawing, obj="obj")
|
||||
|
||||
|
||||
class TestEditTextProduct:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
drawing.get_text_product("element").should_be_called().will_return("existing_product")
|
||||
ifc.run("drawing.unassign_product", relating_product="existing_product", related_object="element").should_be_called()
|
||||
ifc.run("drawing.assign_product", relating_product="product", related_object="element").should_be_called()
|
||||
drawing.update_text_value("obj").should_be_called()
|
||||
drawing.disable_editing_text_product("obj").should_be_called()
|
||||
subject.edit_text_product(ifc, drawing, obj="obj", product="product")
|
||||
|
||||
@@ -37,6 +37,14 @@ class TestDisableEditingText(NewFile):
|
||||
assert obj.BIMTextProperties.is_editing == False
|
||||
|
||||
|
||||
class TestDisableEditingTextProduct(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMTextProperties.is_editing_product = True
|
||||
subject.disable_editing_text_product(obj)
|
||||
assert obj.BIMTextProperties.is_editing_product == False
|
||||
|
||||
|
||||
class TestEnableEditingText(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
@@ -44,6 +52,13 @@ class TestEnableEditingText(NewFile):
|
||||
assert obj.BIMTextProperties.is_editing == True
|
||||
|
||||
|
||||
class TestEnableEditingTextProduct(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.enable_editing_text_product(obj)
|
||||
assert obj.BIMTextProperties.is_editing_product == True
|
||||
|
||||
|
||||
class TestExportTextLiteralAttributes(NewFile):
|
||||
def test_run(self):
|
||||
TestImportTextAttributes().test_run()
|
||||
@@ -69,6 +84,16 @@ class TestGetTextLiteral(NewFile):
|
||||
assert subject.get_text_literal(obj) == item
|
||||
|
||||
|
||||
class TestGetTextProduct(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
wall = ifc.createIfcWall()
|
||||
label = ifc.createIfcAnnotation()
|
||||
ifcopenshell.api.run("drawing.assign_product", ifc, relating_product=wall, related_object=label)
|
||||
assert subject.get_text_product(label) == wall
|
||||
|
||||
|
||||
class TestImportTextAttributes(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -88,6 +113,30 @@ class TestImportTextAttributes(NewFile):
|
||||
assert props.attributes.get("BoxAlignment").string_value == "BoxAlignment"
|
||||
|
||||
|
||||
class TestImportTextProduct(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
wall = ifc.createIfcWall()
|
||||
label = ifc.createIfcAnnotation()
|
||||
ifcopenshell.api.run("drawing.assign_product", ifc, relating_product=wall, related_object=label)
|
||||
wall_obj = bpy.data.objects.new("Object", None)
|
||||
label_obj = bpy.data.objects.new("Object", None)
|
||||
tool.Ifc.link(wall, wall_obj)
|
||||
tool.Ifc.link(label, label_obj)
|
||||
subject.import_text_product(label_obj)
|
||||
assert label_obj.BIMTextProperties.relating_product == wall_obj
|
||||
|
||||
def test_doing_nothing_if_no_product_to_import(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
label = ifc.createIfcAnnotation()
|
||||
label_obj = bpy.data.objects.new("Object", None)
|
||||
tool.Ifc.link(label, label_obj)
|
||||
subject.import_text_product(label_obj)
|
||||
assert label_obj.BIMTextProperties.relating_product is None
|
||||
|
||||
|
||||
class TestUpdateTextValue(NewFile):
|
||||
def test_run(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
|
||||
Reference in New Issue
Block a user