replace api.run with static methods

This commit is contained in:
Andrej
2025-06-09 10:59:22 +05:00
parent 02d359d0e6
commit 8b4683aef1
122 changed files with 1334 additions and 1370 deletions
+12 -12
View File
@@ -19,6 +19,8 @@
import bpy
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.root
import ifcopenshell.api.system
import ifcopenshell.util.unit
import bonsai.core.tool
import bonsai.tool as tool
@@ -150,9 +152,9 @@ class TestExportSystemAttributes(NewFile):
class TestGetConnectedPort(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
port1 = ifcopenshell.api.run("system.add_port", ifc)
port2 = ifcopenshell.api.run("system.add_port", ifc)
ifcopenshell.api.run("system.connect_port", ifc, port1=port1, port2=port2)
port1 = ifcopenshell.api.system.add_port(ifc)
port2 = ifcopenshell.api.system.add_port(ifc)
ifcopenshell.api.system.connect_port(ifc, port1=port1, port2=port2)
assert subject.get_connected_port(port1) == port2
assert subject.get_connected_port(port2) == port1
@@ -163,7 +165,7 @@ class TestGetPorts(NewFile):
tool.Ifc().set(ifc)
element = ifc.createIfcDuctSegment()
port = ifc.createIfcDistributionPort()
ifcopenshell.api.run("system.assign_port", ifc, element=element, port=port)
ifcopenshell.api.system.assign_port(ifc, element=element, port=port)
assert subject.get_ports(element) == [port]
@@ -268,9 +270,9 @@ class TestSelectSystemProducts(NewFile):
assert bpy.context.scene
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
system = ifcopenshell.api.run("system.add_system", ifc, ifc_class="IfcSystem")
ifcopenshell.api.run("system.assign_system", ifc, products=[element], system=system)
element = ifcopenshell.api.root.create_entity(ifc, ifc_class="IfcPump")
system = ifcopenshell.api.system.add_system(ifc, ifc_class="IfcSystem")
ifcopenshell.api.system.assign_system(ifc, products=[element], system=system)
obj = bpy.data.objects.new("Object", None)
bpy.context.scene.collection.objects.link(obj)
tool.Ifc.link(element, obj)
@@ -282,7 +284,7 @@ class TestSetActiveSystem(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
system = ifcopenshell.api.run("system.add_system", ifc, ifc_class="IfcSystem")
system = ifcopenshell.api.system.add_system(ifc, ifc_class="IfcSystem")
subject.set_active_edited_system(system)
props = tool.System.get_system_props()
assert props.edited_system_id == system.id()
@@ -298,14 +300,12 @@ class TestFlowElementAndControls(NewFile):
assert len(subject.get_flow_element_controls(flow_element)) == 0
assert subject.get_flow_control_flow_element(flow_control) == None
ifcopenshell.api.run(
"system.assign_flow_control",
ifcopenshell.api.system.assign_flow_control(
ifc,
related_flow_control=flow_control,
relating_flow_element=flow_element,
)
ifcopenshell.api.run(
"system.assign_flow_control",
ifcopenshell.api.system.assign_flow_control(
ifc,
related_flow_control=flow_control1,
relating_flow_element=flow_element,