IFC element names no longer treat the Blender name suffix as significant

This commit is contained in:
Dion Moult
2022-01-30 15:08:32 +11:00
parent 116252f857
commit 96179db7ad
5 changed files with 136 additions and 123 deletions
+65
View File
@@ -86,3 +86,68 @@ class TestCopyClass:
root.is_opening_element("element").should_be_called().will_return(True)
root.add_dynamic_opening_voids("element", "obj").should_be_called()
subject.copy_class(ifc, collector, geometry, root, obj="obj")
class TestAssignClass:
def test_do_nothing_if_already_assigned(self, ifc, collector, root):
ifc.get_entity("obj").should_be_called().will_return("entity")
subject.assign_class(
ifc,
collector,
root,
obj="obj",
ifc_class="ifc_class",
predefined_type="predefined_type",
should_add_representation=True,
context="context",
ifc_representation_class="ifc_representation_class",
)
def test_assign_a_class_with_geometry_and_autodetected_spatial_container(self, ifc, collector, root):
ifc.get_entity("obj").should_be_called().will_return(None)
root.get_object_name("obj").should_be_called().will_return("name")
ifc.run(
"root.create_entity", ifc_class="ifc_class", predefined_type="predefined_type", name="name"
).should_be_called().will_return("element")
root.set_object_name("obj", "element").should_be_called()
ifc.link("element", "obj").should_be_called()
root.run_geometry_add_representation(
obj="obj", context="context", ifc_representation_class="ifc_representation_class", profile_set_usage=None
).should_be_called()
root.set_element_specific_display_settings("obj", "element").should_be_called()
collector.sync("obj").should_be_called()
collector.assign("obj").should_be_called()
subject.assign_class(
ifc,
collector,
root,
obj="obj",
ifc_class="ifc_class",
predefined_type="predefined_type",
should_add_representation=True,
context="context",
ifc_representation_class="ifc_representation_class",
)
def test_not_adding_a_representation_if_requested(self, ifc, collector, root):
ifc.get_entity("obj").should_be_called().will_return(None)
root.get_object_name("obj").should_be_called().will_return("name")
ifc.run(
"root.create_entity", ifc_class="ifc_class", predefined_type="predefined_type", name="name"
).should_be_called().will_return("element")
root.set_object_name("obj", "element").should_be_called()
ifc.link("element", "obj").should_be_called()
root.set_element_specific_display_settings("obj", "element").should_be_called()
collector.sync("obj").should_be_called()
collector.assign("obj").should_be_called()
subject.assign_class(
ifc,
collector,
root,
obj="obj",
ifc_class="ifc_class",
predefined_type="predefined_type",
should_add_representation=False,
context="context",
ifc_representation_class="ifc_representation_class",
)
+37
View File
@@ -74,6 +74,18 @@ class TestGetElementType(NewFile):
assert subject.get_element_type(element) == type
class TestGetObjectName(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
assert subject.get_object_name(obj) == "Object"
def test_blender_number_suffixes_are_ignored(self):
obj = bpy.data.objects.new("Object.001", None)
assert subject.get_object_name(obj) == "Object"
obj = bpy.data.objects.new("Object.foo.123", None)
assert subject.get_object_name(obj) == "Object.foo"
class TestGetObjectRepresentation(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
@@ -113,3 +125,28 @@ class TestLinkObjectData(NewFile):
class TestRunGeometryAddRepresntation(NewFile):
def test_nothing(self):
pass
class TestSetElementSpecificDisplaySettings(NewFile):
def test_opening_elements_display_as_wire(self):
ifc = ifcopenshell.file()
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
element = ifc.createIfcOpeningElement()
subject.set_element_specific_display_settings(obj, element)
assert obj.display_type == "WIRE"
class TestSetObjectName(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
element = ifc.createIfcWall()
subject.set_object_name(obj, element)
assert obj.name == "IfcWall/Object"
def test_existing_ifc_prefixes_are_not_repeated(self):
ifc = ifcopenshell.file()
obj = bpy.data.objects.new("IfcSlab/Object", bpy.data.meshes.new("Mesh"))
element = ifc.createIfcWall()
subject.set_object_name(obj, element)
assert obj.name == "IfcWall/Object"