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
@@ -69,7 +69,7 @@ def add_axis_representation(
.. code:: python
context = ifcopenshell.util.representation.get_context(model, "Plan", "Axis", "GRAPH_VIEW")
axis = ifcopenshell.api.run("geometry.add_axis_representation", model,
axis = ifcopenshell.api.geometry.add_axis_representation(model,
context=context, axis=[(0.0, 0.0), (1.0, 0.0)])
"""
usecase = Usecase()
@@ -20,6 +20,7 @@ from __future__ import annotations
import collections.abc
import ifcopenshell.util.unit
from ifcopenshell.util.shape_builder import ShapeBuilder, V
import ifcopenshell.api.geometry
from ifcopenshell.api.geometry.add_window_representation import create_ifc_window
from mathutils import Vector
from math import cos, radians
@@ -16,7 +16,8 @@
# 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.owner
import ifcopenshell.api.geometry
import ifcopenshell.util.element
@@ -66,11 +67,11 @@ class Usecase:
types = self.settings["product"].Types
if types:
for element in types[0].RelatedObjects:
mapped_representation = ifcopenshell.api.run(
"geometry.map_representation", self.file, **{"representation": self.settings["representation"]}
mapped_representation = ifcopenshell.api.geometry.map_representation(
self.file, representation=self.settings["representation"]
)
self.assign_product_representation(element, mapped_representation)
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
def assign_product_representation(self, product, representation):
definition = product.Representation
@@ -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
import ifcopenshell.util.element
from typing import Optional
@@ -59,7 +59,7 @@ def connect_element(
return file.createIfcRelConnectsElements(
ifcopenshell.guid.new(),
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
Description=settings["description"],
RelatingElement=settings["relating_element"],
RelatedElement=settings["related_element"],
@@ -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
import ifcopenshell.util.element
from typing import Optional
@@ -89,7 +89,7 @@ def connect_path(
return file.createIfcRelConnectsPathElements(
ifcopenshell.guid.new(),
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
Description=settings["description"],
RelatingElement=settings["relating_element"],
RelatedElement=settings["related_element"],
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import numpy as np
import ifcopenshell.api
import ifcopenshell.api.geometry
import ifcopenshell.util.unit
@@ -64,8 +64,7 @@ class Usecase:
self.settings["p1"][1] = self.convert_unit_to_si(self.settings["p1"][1])
self.settings["elevation"] = self.convert_unit_to_si(self.settings["elevation"])
representation = ifcopenshell.api.run(
"geometry.add_wall_representation",
representation = ifcopenshell.api.geometry.add_wall_representation(
self.file,
context=self.settings["context"],
length=length,
@@ -82,9 +81,7 @@ class Usecase:
[0, 0, 0, 1],
]
)
ifcopenshell.api.run(
"geometry.edit_object_placement", self.file, product=self.settings["element"], matrix=matrix
)
ifcopenshell.api.geometry.edit_object_placement(self.file, product=self.settings["element"], matrix=matrix)
return representation
def convert_unit_to_si(self, co):
@@ -18,7 +18,7 @@
import numpy as np
import numpy.typing as npt
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.util.unit
import ifcopenshell.util.element
import ifcopenshell.util.placement
@@ -77,7 +77,7 @@ class Usecase:
new_placement.PlacementRelTo = placement_rel_to
self.settings["product"].ObjectPlacement = new_placement
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
ifcopenshell.api.owner.update_owner_history(self.file, **{"element": self.settings["product"]})
for settings in children_settings:
self.settings = settings
@@ -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.geometry
import ifcopenshell.util.element
@@ -81,4 +81,4 @@ class Usecase:
for item in mapped_representations:
self.unassign_product_representation(item["product"], item["representation"])
for representation in just_representations:
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
ifcopenshell.api.geometry.remove_representation(self.file, **{"representation": representation})