mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -18,7 +18,10 @@
|
||||
|
||||
import numpy
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.system
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.placement
|
||||
import ifcopenshell.util.system
|
||||
|
||||
@@ -26,22 +29,22 @@ import ifcopenshell.util.system
|
||||
class TestAssignPort(test.bootstrap.IFC4):
|
||||
def test_assigning_a_port_once_only(self):
|
||||
port = self.file.createIfcDistributionPort()
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
|
||||
ifc2x3 = self.file.schema == "IFC2X3"
|
||||
if ifc2x3:
|
||||
assert element.HasPorts[0].RelatingPort == port
|
||||
else:
|
||||
assert element.IsNestedBy[0].RelatedObjects == (port,)
|
||||
assert ifcopenshell.util.system.get_ports(element) == [port]
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
|
||||
assert ifcopenshell.util.system.get_ports(element) == [port]
|
||||
|
||||
def test_updating_the_placement_to_be_relative_if_it_exists(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.run("system.add_port", self.file)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.system.add_port(self.file)
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -58,13 +61,13 @@ class TestAssignPort(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=subelement)
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element, port=subelement)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
Reference in New Issue
Block a user