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
@@ -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
@@ -57,9 +57,9 @@ def assign_product(
.. code:: python
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
ifcopenshell.api.run("drawing.assign_product", model,
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
ifcopenshell.api.drawing.assign_product(model,
relating_product=furniture, related_object=annotation)
"""
settings = {
@@ -99,13 +99,13 @@ def assign_product(
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(settings["related_object"])
referenced_by.RelatedObjects = related_objects
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": referenced_by})
ifcopenshell.api.owner.update_owner_history(file, **{"element": referenced_by})
else:
referenced_by = file.create_entity(
"IfcRelAssignsToProduct",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [settings["related_object"]],
"RelatingProduct": settings["relating_product"],
},
@@ -39,7 +39,7 @@ def edit_text_literal(
.. code:: python
text = model.createIfcTextLiteral()
ifcopenshell.api.run("drawing.edit_text_literal", model,
ifcopenshell.api.drawing.edit_text_literal(model,
text_literal=text, attributes={"Literal": "MY ANNOTATION"})
"""
settings = {"text_literal": text_literal, "attributes": attributes or {}}
@@ -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
@@ -45,13 +45,13 @@ def unassign_product(
.. code:: python
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
ifcopenshell.api.run("drawing.assign_product", model,
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
ifcopenshell.api.drawing.assign_product(model,
relating_product=furniture, related_object=annotation)
# Let's change our mind and remove the relationship
ifcopenshell.api.run("drawing.unassign_product", model,
ifcopenshell.api.drawing.unassign_product(model,
relating_product=furniture, related_object=annotation)
"""
settings = {
@@ -71,4 +71,4 @@ def unassign_product(
related_objects = list(rel.RelatedObjects)
related_objects.remove(settings["related_object"])
rel.RelatedObjects = related_objects
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, element=rel)