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
from typing import Optional
@@ -46,7 +46,7 @@ def add_group(
.. code:: python
ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
ifcopenshell.api.group.add_group(model, name="Unit 1A")
"""
settings = {
"name": name or "Unnamed",
@@ -57,7 +57,7 @@ def add_group(
"IfcGroup",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"Name": settings["name"],
"Description": settings["description"],
}
@@ -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
from typing import Union
@@ -42,8 +42,8 @@ def assign_group(
.. code:: python
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
ifcopenshell.api.run("group.assign_group", model,
group = ifcopenshell.api.group.add_group(model, name="Furniture")
ifcopenshell.api.group.assign_group(model,
products=model.by_type("IfcFurniture"), group=group)
"""
settings = {
@@ -59,7 +59,7 @@ def assign_group(
"IfcRelAssignsToGroup",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": settings["products"],
"RelatingGroup": settings["group"],
}
@@ -70,5 +70,5 @@ def assign_group(
if products.issubset(related_objects):
return rel
rel.RelatedObjects = list(related_objects | products)
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
return rel
@@ -36,8 +36,8 @@ def edit_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance, att
.. code:: python
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
ifcopenshell.api.run("group.edit_group", model,
group = ifcopenshell.api.group.add_group(model, name="Unit 1A")
ifcopenshell.api.group.edit_group(model,
group=group, attributes={"Description": "All furniture and joinery included in the unit"})
"""
settings = {"group": group, "attributes": attributes}
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.pset
import ifcopenshell.util.element
@@ -36,8 +36,8 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
.. code:: python
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
ifcopenshell.api.run("group.remove_group", model, group=group)
group = ifcopenshell.api.group.add_group(model, name="Unit 1A")
ifcopenshell.api.group.remove_group(model, group=group)
"""
settings = {"group": group}
@@ -47,8 +47,7 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
except:
continue
if inverse.is_a("IfcRelDefinesByProperties"):
ifcopenshell.api.run(
"pset.remove_pset",
ifcopenshell.api.pset.remove_pset(
file,
product=settings["group"],
pset=inverse.RelatingPropertyDefinition,
@@ -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
@@ -39,12 +39,12 @@ def unassign_group(
.. code:: python
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
group = ifcopenshell.api.group.add_group(model, name="Furniture")
furniture = model.by_type("IfcFurniture")
ifcopenshell.api.run("group.assign_group", model, products=furniture, group=group)
ifcopenshell.api.group.assign_group(model, products=furniture, group=group)
bad_furniture = furniture[0]
ifcopenshell.api.run("group.unassign_group", model, products=[bad_furniture], group=group)
ifcopenshell.api.group.unassign_group(model, products=[bad_furniture], group=group)
"""
settings = {
"products": products,
@@ -59,7 +59,7 @@ def unassign_group(
related_objects -= products
if 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)
@@ -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
@@ -41,8 +41,8 @@ def update_group_products(
.. code:: python
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
ifcopenshell.api.run("group.update_group_products", model,
group = ifcopenshell.api.group.add_group(model, name="Furniture")
ifcopenshell.api.group.update_group_products(model,
products=model.by_type("IfcFurniture"), group=group)
"""
settings = {
@@ -55,7 +55,7 @@ def update_group_products(
"IfcRelAssignsToGroup",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": settings["products"],
"RelatingGroup": settings["group"],
}