mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 16:22:53 +00:00
You can now show and hide distribution ports of an element.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
# We always call the module we're testing the "test subject". This makes our
|
||||
# tests simple to read: just look for where the "subject" is called!
|
||||
import blenderbim.core.demo as subject
|
||||
|
||||
# These are like mocks, stubs, or spy objects. They don't do anything, but they
|
||||
# let us check our test expectations.
|
||||
from test.core.bootstrap import ifc, demo
|
||||
|
||||
@@ -88,3 +88,18 @@ class TestSelectSystemProducts:
|
||||
def test_run(self, system):
|
||||
system.select_system_products("system").should_be_called()
|
||||
subject.select_system_products(system, system="system")
|
||||
|
||||
|
||||
class TestShowPorts:
|
||||
def test_run(self, system):
|
||||
system.get_ports("element").should_be_called().will_return(["port"])
|
||||
system.load_ports(["port"]).should_be_called()
|
||||
system.select_elements(["port"]).should_be_called()
|
||||
subject.show_ports(system, element="element")
|
||||
|
||||
|
||||
class TestHidePorts:
|
||||
def test_run(self, system):
|
||||
system.get_ports("element").should_be_called().will_return(["port"])
|
||||
system.delete_element_objects(["port"]).should_be_called()
|
||||
subject.hide_ports(system, element="element")
|
||||
|
||||
@@ -350,11 +350,7 @@ class TestRemoveBrick(NewFile):
|
||||
BrickStore.graph = brickschema.Graph()
|
||||
result = subject.add_brick("http://example.org/digitaltwin#", "https://brickschema.org/schema/Brick#Equipment")
|
||||
subject.remove_brick(result)
|
||||
assert not list(
|
||||
BrickStore.graph.triples(
|
||||
(URIRef(result), None, None)
|
||||
)
|
||||
)
|
||||
assert not list(BrickStore.graph.triples((URIRef(result), None, None)))
|
||||
|
||||
|
||||
class TestRunAssignBrickReference(NewFile):
|
||||
|
||||
@@ -48,5 +48,5 @@ class TestGenerateOccurrenceName(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType()
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_style = "CUSTOM"
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_function = "\"Foobar\""
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_function = '"Foobar"'
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
|
||||
@@ -29,6 +29,17 @@ class TestImplementsTool(NewFile):
|
||||
assert isinstance(subject(), blenderbim.core.tool.System)
|
||||
|
||||
|
||||
class TestDeleteElementObjects(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc().set(ifc)
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
element = ifc.createIfcWall()
|
||||
tool.Ifc.link(element, obj)
|
||||
subject.delete_element_objects([element])
|
||||
assert not bpy.data.objects.get("Object")
|
||||
|
||||
|
||||
class TestDisableEditingSystem(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMSystemProperties.active_system_id = 10
|
||||
@@ -60,6 +71,16 @@ class TestExportSystemAttributes(NewFile):
|
||||
}
|
||||
|
||||
|
||||
class TestGetPorts(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc().set(ifc)
|
||||
element = ifc.createIfcDuctSegment()
|
||||
port = ifc.createIfcDistributionPort()
|
||||
ifcopenshell.api.run("system.assign_port", ifc, element=element, port=port)
|
||||
subject.get_ports(element) == [port]
|
||||
|
||||
|
||||
class TestImportSystemAttributes(NewFile):
|
||||
def test_importing_a_system(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -129,6 +150,32 @@ class TestImportSystems(NewFile):
|
||||
assert props.systems[0].ifc_class == "IfcDistributionSystem"
|
||||
|
||||
|
||||
class TestLoadPorts(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.api.run("project.create_file")
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc)
|
||||
tool.Ifc().set(ifc)
|
||||
port = ifc.createIfcDistributionPort()
|
||||
subject.load_ports([port])
|
||||
obj = tool.Ifc.get_object(port)
|
||||
assert obj
|
||||
assert obj.users_collection
|
||||
assert list(obj.location) == [0, 0, 0]
|
||||
|
||||
|
||||
class TestSelectElements(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc().set(ifc)
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
tool.Ifc.link(element, obj)
|
||||
subject.select_elements([element])
|
||||
assert obj in bpy.context.selected_objects
|
||||
|
||||
|
||||
class TestSelectSystemProducts(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
Reference in New Issue
Block a user