Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
import ifcopenshell.api.root
from typing import Literal
@@ -65,8 +65,7 @@ def add_structural_activity(
"structural_member": structural_member,
}
activity = ifcopenshell.api.run(
"root.create_entity",
activity = ifcopenshell.api.root.create_entity(
file,
ifc_class=settings["ifc_class"],
predefined_type=settings["predefined_type"],
@@ -74,7 +73,7 @@ def add_structural_activity(
activity.AppliedLoad = settings["applied_load"]
activity.GlobalOrLocal = settings["global_or_local"]
rel = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcRelConnectsStructuralActivity")
rel = ifcopenshell.api.root.create_entity(file, ifc_class="IfcRelConnectsStructuralActivity")
rel.RelatingElement = settings["structural_member"]
rel.RelatedStructuralActivity = activity
return activity
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.root
def add_structural_analysis_model(file: ifcopenshell.file) -> ifcopenshell.entity_instance:
@@ -37,8 +37,8 @@ def add_structural_analysis_model(file: ifcopenshell.file) -> ifcopenshell.entit
.. code:: python
# Create a fresh blank structural analysis
analysis = ifcopenshell.api.run("structural.add_structural_analysis_model", model)
analysis = ifcopenshell.api.structural.add_structural_analysis_model(model)
"""
return ifcopenshell.api.run(
"root.create_entity", file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D"
return ifcopenshell.api.root.create_entity(
file, ifc_class="IfcStructuralAnalysisModel", predefined_type="LOADING_3D"
)
@@ -49,7 +49,7 @@ def add_structural_boundary_condition(
.. code:: python
ifcopenshell.api.run("structural.add_structural_boundary_condition", model, connection=connection)
ifcopenshell.api.structural.add_structural_boundary_condition(model, connection=connection)
"""
settings = {"name": name, "connection": connection, "ifc_class": ifc_class}
@@ -43,6 +43,6 @@ def add_structural_load(
.. code:: python
# Create a simple linear load
ifcopenshell.api.run("structural.add_structural_load", model)
ifcopenshell.api.structural.add_structural_load(model)
"""
return file.create_entity(ifc_class, Name=name)
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
import ifcopenshell.api.root
def add_structural_load_case(
@@ -37,8 +37,7 @@ def add_structural_load_case(
:rtype: ifcopenshell.entity_instance
"""
load_case = ifcopenshell.api.run(
"root.create_entity",
load_case = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcStructuralLoadCase",
predefined_type="LOAD_CASE",
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell.api
import ifcopenshell.api.root
def add_structural_load_group(
@@ -37,8 +37,7 @@ def add_structural_load_group(
:rtype: ifcopenshell.entity_instance
"""
load_group = ifcopenshell.api.run(
"root.create_entity",
load_group = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcStructuralLoadGroup",
predefined_type="LOAD_GROUP",
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.root
def add_structural_member_connection(
@@ -44,7 +44,7 @@ def add_structural_member_connection(
for connection in settings["related_structural_connection"].ConnectsStructuralMembers or []:
if connection.RelatingStructuralMember == settings["relating_structural_member"]:
return connection
rel = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcRelConnectsStructuralMember")
rel = ifcopenshell.api.root.create_entity(file, ifc_class="IfcRelConnectsStructuralMember")
rel.RelatingStructuralMember = settings["relating_structural_member"]
rel.RelatedStructuralConnection = settings["related_structural_connection"]
return rel
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -46,7 +46,7 @@ def assign_structural_analysis_model(
"IfcRelAssignsToGroup",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [settings["product"]],
"RelatingGroup": settings["structural_analysis_model"],
}
@@ -55,5 +55,5 @@ def assign_structural_analysis_model(
related_objects = set(rel.RelatedObjects) or set()
related_objects.add(settings["product"])
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
return rel
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.structural
import ifcopenshell.util.element
@@ -34,8 +34,7 @@ def remove_structural_connection_condition(file: ifcopenshell.file, relation: if
settings = {"relation": relation}
if settings["relation"].AppliedCondition:
ifcopenshell.api.run(
"structural.remove_structural_boundary_condition",
ifcopenshell.api.structural.remove_structural_boundary_condition(
file,
connection=settings["relation"].RelatedStructuralConnection,
)
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -48,7 +48,7 @@ def unassign_structural_analysis_model(
related_objects.remove(settings["product"])
if len(related_objects):
rel.RelatedObjects = list(related_objects)
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
else:
history = rel.OwnerHistory
file.remove(rel)