diff --git a/src/ifcopenshell-python/ifcopenshell/api/aggregate/assign_object.py b/src/ifcopenshell-python/ifcopenshell/api/aggregate/assign_object.py
index 4490266186..dac156daea 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/aggregate/assign_object.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/aggregate/assign_object.py
@@ -17,7 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.placement
@@ -74,15 +76,15 @@ def assign_object(
.. code:: python
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- subelement = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ subelement = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
# The project contains a site (note that project aggregation is a special case in IFC)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[element], relating_object=project)
+ ifcopenshell.api.aggregate.assign_object(model, products=[element], relating_object=project)
# The site has a building
- ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement], relating_object=element)
+ ifcopenshell.api.aggregate.assign_object(model, products=[subelement], relating_object=element)
"""
settings = {
"products": products,
@@ -123,14 +125,14 @@ def assign_object(
# can be either only aggregated or only contained at the same time
# some product might not be able to have a container
possibly_contained_products = [p for p in products_without_aggregates if hasattr(p, "ContainedInStructure")]
- ifcopenshell.api.run("spatial.unassign_container", file, products=possibly_contained_products)
+ ifcopenshell.api.spatial.unassign_container(file, products=possibly_contained_products)
# unassign elements from previous aggregates
for decomposes in previous_aggregates_rels:
related_objects = set(decomposes.RelatedObjects) - products
if related_objects:
decomposes.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": decomposes})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": decomposes})
else:
history = decomposes.OwnerHistory
file.remove(decomposes)
@@ -140,13 +142,13 @@ def assign_object(
# assign elements to a new aggregate
if is_decomposed_by:
is_decomposed_by.RelatedObjects = list(set(is_decomposed_by.RelatedObjects) | products)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": is_decomposed_by})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": is_decomposed_by})
else:
is_decomposed_by = file.create_entity(
"IfcRelAggregates",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": list(products),
"RelatingObject": relating_object,
}
@@ -156,8 +158,7 @@ def assign_object(
for product in products_to_change:
placement = getattr(product, "ObjectPlacement", None)
if placement and placement.is_a("IfcLocalPlacement"):
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
file,
product=product,
matrix=ifcopenshell.util.placement.get_local_placement(product.ObjectPlacement),
diff --git a/src/ifcopenshell-python/ifcopenshell/api/aggregate/unassign_object.py b/src/ifcopenshell-python/ifcopenshell/api/aggregate/unassign_object.py
index 8a8e35a948..2c0461fe38 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/aggregate/unassign_object.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/aggregate/unassign_object.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -46,15 +46,15 @@ def unassign_object(file: ifcopenshell.file, products: list[ifcopenshell.entity_
.. code:: python
- element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- subelement1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- subelement2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement1], relating_object=element)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[subelement2], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ subelement1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ subelement2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(model, products=[subelement1], relating_object=element)
+ ifcopenshell.api.aggregate.assign_object(model, products=[subelement2], relating_object=element)
# nothing is returned
- ifcopenshell.api.run("aggregate.unassign_object", model, products=[subelement1])
+ ifcopenshell.api.aggregate.unassign_object(model, products=[subelement1])
# nothing is returned, relationship is removed
- ifcopenshell.api.run("aggregate.unassign_object", model, products=[subelement2])
+ ifcopenshell.api.aggregate.unassign_object(model, products=[subelement2])
"""
settings = {"products": products}
@@ -69,7 +69,7 @@ def unassign_object(file: ifcopenshell.file, products: list[ifcopenshell.entity_
related_objects = set(rel.RelatedObjects) - 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py b/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py
index 650c2c57bd..3babb19013 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/attribute/edit_attributes.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
from typing import Any
@@ -41,8 +41,8 @@ def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instan
.. code:: python
- element = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- ifcopenshell.api.run("attribute.edit_attributes", model,
+ element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ ifcopenshell.api.attribute.edit_attributes(model,
product=element, attributes={"Name": "Waldo"})
"""
settings = {"product": product, "attributes": attributes or {}}
@@ -66,4 +66,4 @@ def edit_attributes(file: ifcopenshell.file, product: ifcopenshell.entity_instan
elif settings["product"].ObjectType and settings["product"].PredefinedType != "USERDEFINED":
settings["product"].PredefinedType = "USERDEFINED"
if hasattr(settings["product"], "OwnerHistory"):
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": settings["product"]})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": settings["product"]})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py
index a5693324e4..d77776f04a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/assign_connection_geometry.py
@@ -74,7 +74,7 @@ def assign_connection_geometry(
.. code:: python
- ifcopenshell.api.run("boundary.assign_connection_geometry", model,
+ ifcopenshell.api.boundary.assign_connection_geometry(model,
rel_space_boundary=element,
outer_boundary=[(0., 0.), (1., 0.), (1., 1.), (0., 1.)],
location=[0., 0., 0.], axis=[1., 0., 0.], ref_direction=[0., 0., 1.],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py
index 791cc09bbb..af2bc72cb2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/copy_boundary.py
@@ -31,10 +31,10 @@ def copy_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_instanc
# A boring boundary with no geometry. Note that this boundary is
# invalid and does not relate to any space or building element.
- boundary = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcRelSpaceBoundary")
+ boundary = ifcopenshell.api.root.create_entity(model, ifc_class="IfcRelSpaceBoundary")
# And now we have two
- boundary_copy = ifcopenshell.api.run("boundary.copy_boundary", model, boundary=boundary)
+ boundary_copy = ifcopenshell.api.boundary.copy_boundary(model, boundary=boundary)
"""
settings = {"boundary": boundary}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py b/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py
index 6962a3121a..13dfb7ab6b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/boundary/remove_boundary.py
@@ -35,10 +35,10 @@ def remove_boundary(file: ifcopenshell.file, boundary: ifcopenshell.entity_insta
# A boring boundary with no geometry. Note that this boundary is
# invalid and does not relate to any space or building element.
- boundary = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcRelSpaceBoundary")
+ boundary = ifcopenshell.api.root.create_entity(model, ifc_class="IfcRelSpaceBoundary")
# Let's remove it!
- ifcopenshell.api.run("boundary.remove_boundary", model, boundary=boundary)
+ ifcopenshell.api.boundary.remove_boundary(model, boundary=boundary)
"""
settings = {"boundary": boundary}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py
index d0e18d265e..f91464a640 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/add_classification.py
@@ -70,13 +70,13 @@ def add_classification(
.. code:: python
# Option 1: adding a custom clasification from scratch
- ifcopenshell.api.run("classification.add_classification", model,
+ ifcopenshell.api.classification.add_classification(model,
classification="MyCustomClassification")
# Option 2: adding a popular classification from a library
library = ifcopenshell.open("/path/to/Uniclass.ifc")
classification = library.by_type("IfcClassification")[0]
- ifcopenshell.api.run("classification.add_classification", model,
+ ifcopenshell.api.classification.add_classification(model,
classification=classification)
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/add_reference.py b/src/ifcopenshell-python/ifcopenshell/api/classification/add_reference.py
index d5d2d94932..1e0ae329bf 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/add_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/add_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.schema
@@ -105,20 +105,20 @@ def add_reference(
# Option 1: adding and assigning a new reference from scratch
wall_type = model.by_type("IfcWallType")[0]
- classification = ifcopenshell.api.run("classification.add_classification",
+ classification = ifcopenshell.api.classification.add_classification(
model, classification="MyCustomClassification")
- ifcopenshell.api.run("classification.add_reference", model,
+ ifcopenshell.api.classification.add_reference(model,
products=[wall_type], classification=classification,
identification="W_01", name="Interior Walls")
# Option 2: adding a popular classification from a library
library = ifcopenshell.open("/path/to/Uniclass.ifc")
lib_classification = library.by_type("IfcClassification")[0]
- classification = ifcopenshell.api.run("classification.add_classification",
+ classification = ifcopenshell.api.classification.add_classification(
model, classification=lib_classification)
reference = [r for r in library.by_type("IfcClassificationReference")
if r.Identification == "XYZ"][0]
- ifcopenshell.api.run("classification.add_reference", model,
+ ifcopenshell.api.classification.add_reference(model,
products=[wall_type], classification=classification,
reference=reference)
"""
@@ -235,11 +235,11 @@ class Usecase:
if root_rel:
related_objects = set(root_rel.RelatedObjects) | self.rooted_products
root_rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": root_rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": root_rel})
else:
self.file.create_entity(
"IfcRelAssociatesClassification",
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
GlobalId=ifcopenshell.guid.new(),
RelatedObjects=list(self.rooted_products),
RelatingClassification=reference,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py
index f7577bdc4c..d6c8ef8bc4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_classification.py
@@ -40,7 +40,7 @@ def edit_classification(
classification = model.by_type("IfcClassification")[0]
# Change the name of the classification system to "Foo"
- ifcopenshell.api.run("classification.edit_classification", model,
+ ifcopenshell.api.classification.edit_classification(model,
classification=classification, attributes={"Name": "Foo"})
"""
settings = {"classification": classification, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py
index d8052a333f..80d978e7d3 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/edit_reference.py
@@ -40,7 +40,7 @@ def edit_reference(
reference = model.by_type("IfcClassification")[0]
# Change the name of the reference to "Foo"
- ifcopenshell.api.run("classification.edit_reference", model,
+ ifcopenshell.api.classification.edit_reference(model,
reference=reference, attributes={"Name": "Foo"})
"""
settings = {"reference": reference, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py
index 0029ac94a0..90e6abbbe7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_classification.py
@@ -37,7 +37,7 @@ def remove_classification(file: ifcopenshell.file, classification: ifcopenshell.
.. code:: python
classification = model.by_type("IfcClassification")[0]
- ifcopenshell.api.run("classification.remove_classification", model,
+ ifcopenshell.api.classification.remove_classification(model,
classification=classification)
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_reference.py b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_reference.py
index bad8406582..0bdd347bfa 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/classification/remove_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/classification/remove_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -48,12 +48,12 @@ def remove_reference(
.. code:: python
wall_type = model.by_type("IfcWallType")[0]
- classification = ifcopenshell.api.run("classification.add_classification",
+ classification = ifcopenshell.api.classification.add_classification(
model, classification="MyCustomClassification")
- reference = ifcopenshell.api.run("classification.add_reference", model,
+ reference = ifcopenshell.api.classification.add_reference(model,
products=[wall_type], classification=classification,
identification="W_01", name="Interior Walls")
- ifcopenshell.api.run("classification.remove_reference", model,
+ ifcopenshell.api.classification.remove_reference(model,
reference=reference, products=[wall_type])
"""
settings = {"reference": reference, "products": products}
@@ -93,7 +93,7 @@ def remove_reference(
related_objects = set(rel.RelatedObjects) - rooted_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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py
index 70ca67a743..f1fcf20a0e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_metric.py
@@ -36,8 +36,8 @@ def add_metric(file: ifcopenshell.file, objective: ifcopenshell.entity_instance)
.. code:: python
- objective = ifcopenshell.api.run("constraint.add_objective", model)
- metric = ifcopenshell.api.run("constraint.add_metric", model,
+ objective = ifcopenshell.api.constraint.add_objective(model)
+ metric = ifcopenshell.api.constraint.add_metric(model,
objective=objective)
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py
index 2d8c0ab8db..064648f1b7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/add_objective.py
@@ -36,7 +36,7 @@ def add_objective(file: ifcopenshell.file) -> ifcopenshell.entity_instance:
.. code:: python
# Create a new objective for code compliance requirements
- objective = ifcopenshell.api.run("constraint.add_objective", model)
+ objective = ifcopenshell.api.constraint.add_objective(model)
objective.ConstraintGrade = "ADVISORY"
objective.ObjectiveQualifier = "CODECOMPLIANCE"
# Note: the objective right now is purely qualitative and for
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/assign_constraint.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/assign_constraint.py
index 646ab57cda..74bf3d9a04 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/assign_constraint.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/assign_constraint.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Union
@@ -77,14 +77,14 @@ class Usecase:
if rel:
related_objects = set(rel.RelatedObjects) | products_to_assign
rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
return rel
return self.file.create_entity(
"IfcRelAssociatesConstraint",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
"RelatingConstraint": self.constraint,
"RelatedObjects": list(products_to_assign),
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py
index f90d1590d9..89a0cbef7d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_metric.py
@@ -36,10 +36,10 @@ def edit_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance, a
.. code:: python
- objective = ifcopenshell.api.run("constraint.add_objective", model)
- metric = ifcopenshell.api.run("constraint.add_metric", model,
+ objective = ifcopenshell.api.constraint.add_objective(model)
+ metric = ifcopenshell.api.constraint.add_metric(model,
objective=objective)
- ifcopenshell.api.run("constraint.edit_metric", model,
+ ifcopenshell.api.constraint.edit_metric(model,
metric=metric, attributes={"ConstraintGrade": "HARD"})
"""
settings = {"metric": metric, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py
index 0004261031..ce4e76ba9e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/edit_objective.py
@@ -38,8 +38,8 @@ def edit_objective(
.. code:: python
- objective = ifcopenshell.api.run("constraint.add_objective", model)
- ifcopenshell.api.run("constraint.edit_objective", model,
+ objective = ifcopenshell.api.constraint.add_objective(model)
+ ifcopenshell.api.constraint.edit_objective(model,
objective=objective, attributes={"ConstraintGrade": "HARD"})
"""
settings = {"objective": objective, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py
index aea342e126..381a9e191e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_constraint.py
@@ -37,8 +37,8 @@ def remove_constraint(file: ifcopenshell.file, constraint: ifcopenshell.entity_i
.. code:: python
- objective = ifcopenshell.api.run("constraint.add_objective", model)
- ifcopenshell.api.run("constraint.remove_constraint", model,
+ objective = ifcopenshell.api.constraint.add_objective(model)
+ ifcopenshell.api.constraint.remove_constraint(model,
constraint=objective)
"""
settings = {"constraint": constraint}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py
index 2829a3355f..f700a2c150 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/remove_metric.py
@@ -33,10 +33,10 @@ def remove_metric(file: ifcopenshell.file, metric: ifcopenshell.entity_instance)
.. code:: python
- objective = ifcopenshell.api.run("constraint.add_objective", model)
- metric = ifcopenshell.api.run("constraint.add_metric", model,
+ objective = ifcopenshell.api.constraint.add_objective(model)
+ metric = ifcopenshell.api.constraint.add_metric(model,
objective=objective)
- ifcopenshell.api.run("constraint.remove_metric", model,
+ ifcopenshell.api.constraint.remove_metric(model,
metric=metric)
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/constraint/unassign_constraint.py b/src/ifcopenshell-python/ifcopenshell/api/constraint/unassign_constraint.py
index 138964e265..cff9716809 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/constraint/unassign_constraint.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/constraint/unassign_constraint.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -69,7 +69,7 @@ class Usecase:
related_objects -= products
if related_objects:
rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
continue
history = rel.OwnerHistory
diff --git a/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py b/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
index 95b38a0f5e..bae2c32ea8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/context/add_context.py
@@ -121,63 +121,63 @@ def add_context(
# If we plan to store 3D geometry in our IFC model, we have to setup
# a "Model" context.
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
# And/Or, if we plan to store 2D geometry, we need a "Plan" context
- plan = ifcopenshell.api.run("context.add_context", model, context_type="Plan")
+ plan = ifcopenshell.api.context.add_context(model, context_type="Plan")
# Now we setup the subcontexts with each of the geometric "purposes"
# we plan to store in our model. "Body" is by far the most important
# and common context, as most IFC models are assumed to be viewable
# in 3D.
- body = ifcopenshell.api.run("context.add_context", model,
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# The 3D Axis subcontext is important if any "axis-based" parametric
# geometry is going to be created. For example, a beam, or column
# may be drawn using a single 3D axis line, and for this we need an
# Axis subcontext.
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Axis", target_view="GRAPH_VIEW", parent=model3d)
# The 3D Box subcontext is useful for clash detection or shape
# analysis, or even lazy-loading of large models.
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Box", target_view="MODEL_VIEW", parent=model3d)
# It's also important to have a 2D Axis subcontext for things like
# walls and claddings which can be drawn using a 2D axis line.
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Plan", context_identifier="Axis", target_view="GRAPH_VIEW", parent=plan)
# A 2D annotation subcontext for plan views are important for door
# swings, window cuts, and symbols for equipment like GPOs, fire
# extinguishers, and so on.
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Plan", context_identifier="Annotation", target_view="PLAN_VIEW", parent=plan)
# You may also create 2D annotation subcontexts for sections and
# elevation views.
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Plan", context_identifier="Annotation", target_view="SECTION_VIEW", parent=plan)
- ifcopenshell.api.run("context.add_context", model,
+ ifcopenshell.api.context.add_context(model,
context_type="Plan", context_identifier="Annotation", target_view="ELEVATION_VIEW", parent=plan)
# Let's create a new wall. The wall does not have any geometry yet.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's use the "3D Body" representation we created earlier to add a
# new wall-like body geometry, 5 meters long, 3 meters high, and
# 200mm thick
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
# Assign our new body geometry back to our wall
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/context/edit_context.py b/src/ifcopenshell-python/ifcopenshell/api/context/edit_context.py
index 5bef4c9956..ba52e83a9e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/context/edit_context.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/context/edit_context.py
@@ -37,14 +37,14 @@ def edit_context(file: ifcopenshell.file, context: ifcopenshell.entity_instance,
.. code:: python
- model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
+ model = ifcopenshell.api.context.add_context(model, context_type="Model")
# Revit had a bug where they incorrectly called the body representation a "Facetation"
- body = ifcopenshell.api.run("context.add_context", model,
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Facetation", target_view="MODEL_VIEW", parent=model
)
# Let's fix it!
- ifcopenshell.api.run("context.edit_context", model,
+ ifcopenshell.api.context.edit_context(model,
context=body, attributes={"ContextIdentifier": "Body"})
"""
settings = {"context": context, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py b/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py
index e80cbddaf6..2d6defeaf3 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/context/remove_context.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.context
+import ifcopenshell.api.geometry
import ifcopenshell.util.element
@@ -36,19 +37,19 @@ def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instanc
.. code:: python
- model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
+ model = ifcopenshell.api.context.add_context(model, context_type="Model")
# Revit had a bug where they incorrectly called the body representation a "Facetation"
- body = ifcopenshell.api.run("context.add_context", model,
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Facetation", target_view="MODEL_VIEW", parent=model
)
# Let's just get rid of it completely
- ifcopenshell.api.run("context.remove_context", model, context=body)
+ ifcopenshell.api.context.remove_context(model, context=body)
"""
settings = {"context": context}
for subcontext in settings["context"].HasSubContexts:
- ifcopenshell.api.run("context.remove_context", file, context=subcontext)
+ ifcopenshell.api.context.remove_context(file, context=subcontext)
if getattr(settings["context"], "ParentContext", None):
new = settings["context"].ParentContext
@@ -63,4 +64,4 @@ def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instanc
representations_in_context = settings["context"].RepresentationsInContext
file.remove(settings["context"])
for element in representations_in_context:
- ifcopenshell.api.run("geometry.remove_representation", file, representation=element)
+ ifcopenshell.api.geometry.remove_representation(file, representation=element)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py
index b9ca8ab9d0..303cfa6726 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Union
@@ -54,22 +54,22 @@ def assign_control(
.. code:: python
# One common usecase is to assign a calendar to a task
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model)
- task = ifcopenshell.api.run("sequence.add_task", model,
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model)
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule)
# All subtasks will inherit this calendar, so assigning a single
# calendar to the root task effectively defines a "default" calendar
- ifcopenshell.api.run("control.assign_control", model,
+ ifcopenshell.api.control.assign_control(model,
relating_control=calendar, related_object=task)
# Another common example might be relating a cost item and a product
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- cost_item = ifcopenshell.api.run("cost.add_cost_item", model,
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ cost_item = ifcopenshell.api.cost.add_cost_item(model,
cost_schedule=schedule)
- ifcopenshell.api.run("control.assign_control", model,
+ ifcopenshell.api.control.assign_control(model,
relating_control=cost_item, related_object=wall)
"""
settings = {
@@ -92,13 +92,13 @@ def assign_control(
related_objects = set(controls.RelatedObjects)
related_objects.add(settings["related_object"])
controls.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": controls})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": controls})
else:
controls = file.create_entity(
"IfcRelAssignsToControl",
**{
"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"]],
"RelatingControl": settings["relating_control"],
},
diff --git a/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py b/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py
index f2d4cc8a9b..77530316d8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/control/unassign_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
from typing import Union
@@ -43,15 +43,15 @@ def unassign_control(
.. code:: python
# Let's relate a cost item and a product
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- cost_item = ifcopenshell.api.run("cost.add_cost_item", model,
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ cost_item = ifcopenshell.api.cost.add_cost_item(model,
cost_schedule=schedule)
- ifcopenshell.api.run("control.assign_control", model,
+ ifcopenshell.api.control.assign_control(model,
relating_control=cost_item, related_object=wall)
# And now let's change our mind
- ifcopenshell.api.run("control.unassign_control", model,
+ ifcopenshell.api.control.unassign_control(model,
relating_control=cost_item, related_object=wall)
"""
@@ -72,5 +72,5 @@ def unassign_control(
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})
return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py
index a33c17c890..444f42a589 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py
@@ -16,7 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.nest
+import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Optional
@@ -49,30 +51,30 @@ def add_cost_item(
.. code:: python
# The very first cost item must be in a cost schedule
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
# You may add cost items as top level item in the schedule
- item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Alternatively you may add them as subitems
- item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_item=item1)
+ item2 = ifcopenshell.api.cost.add_cost_item(model, cost_item=item1)
"""
settings = {"cost_schedule": cost_schedule, "cost_item": cost_item}
- cost_item = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcCostItem")
+ cost_item = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
if settings["cost_schedule"]:
file.create_entity(
"IfcRelAssignsToControl",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [cost_item],
"RelatingControl": settings["cost_schedule"],
},
)
elif settings["cost_item"]:
- ifcopenshell.api.run(
- "nest.assign_object", file, related_objects=[cost_item], relating_object=settings["cost_item"]
+ ifcopenshell.api.nest.assign_object(
+ file, related_objects=[cost_item], relating_object=settings["cost_item"]
)
return cost_item
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py
index 59a3f1f8a2..c2a020cac8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py
@@ -65,15 +65,15 @@ def add_cost_item_quantity(
.. code:: python
- chair = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- ifcopenshell.api.run("control.assign_control", model,
+ chair = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ ifcopenshell.api.control.assign_control(model,
relating_control=item, related_object=chair)
# Let's assume we want to count the amount of chairs to calculate our cost item
# Because this is an IfcQuantityCount the count will be automatically set to "1" chair
- ifcopenshell.api.run("cost.add_cost_item_quantity", model,
+ ifcopenshell.api.cost.add_cost_item_quantity(model,
cost_item=item, ifc_class="IfcQuantityCount")
"""
settings = {"cost_item": cost_item, "ifc_class": ifc_class}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py
index cb8e678420..2231c8c07f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_schedule.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
import ifcopenshell.util.date
from datetime import datetime
from typing import Optional
@@ -51,14 +51,13 @@ def add_cost_schedule(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
# Now that we have a cost schedule, we may add cost items to it
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
"""
settings = {"name": name, "predefined_type": predefined_type}
- cost_schedule = ifcopenshell.api.run(
- "root.create_entity",
+ cost_schedule = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcCostSchedule",
predefined_type=settings["predefined_type"],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py
index 6c59af0bb6..ebee87ee44 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_value.py
@@ -55,40 +55,40 @@ def add_cost_value(file: ifcopenshell.file, parent: ifcopenshell.entity_instance
.. code:: python
# We always need a schedule first prior to adding any cost items
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
# Option 1: This cost item will have a full cost of 42.0
- item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 42.0})
# Option 2: This cost item will have a unit cost of 5.0 per unit
# area, multiplied by the quantity of area specified explicitly as
# 3.0, giving us a subtotal cost of 15.0.
- item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item2)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ item2 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item2)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
- quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
+ quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
cost_item=item2, ifc_class="IfcQuantityVolume")
- ifcopenshell.api.run("cost.edit_cost_item_quantity", model,
+ ifcopenshell.api.cost.edit_cost_item_quantity(model,
physical_quantity=quantity, "attributes": {"VolumeValue": 3.0})
# A cost value may also be specified in terms of the sum of its
# subcomponents. In this case, it's broken down into 2 subvalues.
- item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
- subvalue1 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
- subvalue2 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
+ item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
+ subvalue1 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
+ subvalue2 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
# This specifies that the value is the sum of all subitems
# regardless of their cost category. The first subvalue is 2.0 and
# the second is 3.0, giving a total value of 5.0.
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value, attributes={"Category": "*"})
- ifcopenshell.api.run("cost.edit_cost_value", model,
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value, attributes={"Category": "*"})
+ ifcopenshell.api.cost.edit_cost_value(model,
cost_value=subvalue1, attributes={"AppliedValue": 2.0})
- ifcopenshell.api.run("cost.edit_cost_value", model,
+ ifcopenshell.api.cost.edit_cost_value(model,
cost_value=subvalue2, attributes={"AppliedValue": 3.0})
"""
settings = {"parent": parent}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py
index d9ef5c61f6..a1c0b9a706 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.cost
+import ifcopenshell.api.control
from typing import Any
@@ -63,26 +64,26 @@ def assign_cost_item_quantity(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Let's imagine a unit cost of 5.0 per unit volume
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
- slab = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSlab")
+ slab = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSlab")
# Usually the quantity would be automatically calculated via a
# graphical authoring application but let's assign a manual quantity
# for now.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"NetVolume": 42.0})
+ qto = ifcopenshell.api.pset.add_qto(model, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"NetVolume": 42.0})
# Now let's parametrically link the slab's quantity to the cost
# item. If the slab is edited in the future and 42.0 changes, then
# the updated value will also automatically be applied to the cost
# item.
- ifcopenshell.api.run("cost.assign_cost_item_quantity", model,
+ ifcopenshell.api.cost.assign_cost_item_quantity(model,
cost_item=item, products=[slab], prop_name="NetVolume")
"""
usecase = Usecase()
@@ -119,8 +120,7 @@ class Usecase:
def assign_cost_control(
self, related_object: ifcopenshell.entity_instance, cost_item: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
- return ifcopenshell.api.run(
- "control.assign_control",
+ return ifcopenshell.api.control.assign_control(
self.file,
related_object=related_object,
relating_control=cost_item,
@@ -142,8 +142,7 @@ class Usecase:
# This is a bold assumption
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
if not self.settings["cost_item"].CostQuantities:
- ifcopenshell.api.run(
- "cost.add_cost_item_quantity",
+ ifcopenshell.api.cost.add_cost_item_quantity(
self.file,
cost_item=self.settings["cost_item"],
ifc_class="IfcQuantityCount",
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py
index dda9d509eb..2eeb02f89d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.cost
def assign_cost_value(
@@ -47,26 +47,25 @@ def assign_cost_value(
.. code:: python
# Let's create a schedule of rates with a single rate in it of 5.0
- rate_tables = ifcopenshell.api.run("cost.add_cost_schedule", model,
+ rate_tables = ifcopenshell.api.cost.add_cost_schedule(model,
predefined_type="SCHEDULEOFRATES")
- rate = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=rate)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ rate = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=rate)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
# And this schedule will be for our actual cost plan / estimate / etc
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Now the cost item has the same rate as the one from the schedule of rate's item
- ifcopenshell.api.run("cost.assign_cost_value", model, cost_item=item, cost_rate=rate)
+ ifcopenshell.api.cost.assign_cost_value(model, cost_item=item, cost_rate=rate)
"""
settings = {"cost_item": cost_item, "cost_rate": cost_rate}
if settings["cost_item"].CostValues:
[
- ifcopenshell.api.run(
- "cost.remove_cost_value",
+ ifcopenshell.api.cost.remove_cost_value(
file,
parent=settings["cost_item"],
cost_value=cost_value,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py
index 897a2d7412..c58bd7e657 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.cost
import ifcopenshell.util.date
import ifcopenshell.util.resource
@@ -49,44 +49,44 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop
.. code:: python
# First, we need a cost schedule and item
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Let's imagine we have our own formworking crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# ... and they need concrete
- concrete = ifcopenshell.api.run("resource.add_resource", model,
+ concrete = ifcopenshell.api.resource.add_resource(model,
ifc_class="IfcConstructionMaterialResource", parent_resource=crew)
- ifcopenshell.api.run("control.assign_control", model,
+ ifcopenshell.api.control.assign_control(model,
relating_control=item, related_object=concrete)
# ... which has a unit price of 42.0 per m3
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=concrete)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 42.0})
# ... and a volume of 200m3
- quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
+ quantity = ifcopenshell.api.resource.add_resource_quantity(model,
resource=concrete, ifc_class="IfcQuantityVolume")
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=quantity, "attributes": {"VolumeValue": 200.0})
# Let's say they also need some equipment
- equipment = ifcopenshell.api.run("resource.add_resource", model,
+ equipment = ifcopenshell.api.resource.add_resource(model,
ifc_class="IfcConstructionEquipmentResource", parent_resource=crew)
- ifcopenshell.api.run("control.assign_control", model,
+ ifcopenshell.api.control.assign_control(model,
relating_control=item, related_object=equipment)
# ... with a fixed price of 50,000
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=concrete)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 42.0})
# (42 * 200) + 50000 = 58400 is our calculated cost
- ifcopenshell.api.run("cost.calculate_cost_item_resource_value", model, cost_item=item)
+ ifcopenshell.api.cost.calculate_cost_item_resource_value(model, cost_item=item)
"""
settings = {"cost_item": cost_item}
for cost_value in settings["cost_item"].CostValues or []:
- ifcopenshell.api.run("cost.remove_cost_value", file, parent=settings["cost_item"], cost_value=cost_value)
+ ifcopenshell.api.cost.remove_cost_value(file, parent=settings["cost_item"], cost_value=cost_value)
resources = []
for rel in settings["cost_item"].Controls or []:
@@ -112,6 +112,6 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop
quantity = quantity / 8 # Assume 8 hour working day - TODO implement resource calendar
quantity = round(quantity, 2)
formula = "{}*{}".format(cost, quantity)
- cost_value = ifcopenshell.api.run("cost.add_cost_value", file, parent=settings["cost_item"])
+ cost_value = ifcopenshell.api.cost.add_cost_value(file, parent=settings["cost_item"])
cost_value.Name = resource.Name
- ifcopenshell.api.run("cost.edit_cost_value_formula", file, cost_value=cost_value, formula=formula)
+ ifcopenshell.api.cost.edit_cost_value_formula(file, cost_value=cost_value, formula=formula)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py
index 7b08df16a5..ac6b563960 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.nest
import ifcopenshell.util.element
from typing import Union
@@ -85,12 +85,9 @@ class Usecase:
inverse = ifcopenshell.util.element.copy(self.file, inverse)
inverse.RelatingObject = to_element
inverse.RelatedObjects = new_cost_items
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=new_cost_items)
- ifcopenshell.api.run(
- "nest.assign_object",
- self.file,
- related_objects=new_cost_items,
- relating_object=to_element,
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=new_cost_items)
+ ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=new_cost_items, relating_object=to_element
)
# elif inverse.is_a("IfcRelAssignsToProduct"):
# continue
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py
index 6fadb9a349..6903f41bfe 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_item_values.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell.util.element
-import ifcopenshell.api
+import ifcopenshell.api.cost
def copy_cost_item_values(
@@ -41,22 +41,22 @@ def copy_cost_item_values(
.. code:: python
# Assume we have a schedule with multiple items in it
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# One of the items has a value
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5000.0})
# Let's copy the value from one item to another
- ifcopenshell.api.run("cost.copy_cost_item_values", model, source=item1, destination=item2)
+ ifcopenshell.api.cost.copy_cost_item_values(model, source=item1, destination=item2)
"""
settings = {"source": source, "destination": destination}
for cost_value in settings["destination"].CostValues or []:
- ifcopenshell.api.run("cost.remove_cost_item_value", file, cost_value=cost_value)
+ ifcopenshell.api.cost.remove_cost_item_value(file, cost_value=cost_value)
copied_cost_values = []
for cost_value in settings["source"].CostValues or []:
copied_cost_values.append(ifcopenshell.util.element.copy_deep(file, cost_value))
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py
index 4d168173b6..2417c9ac65 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item.py
@@ -38,9 +38,9 @@ def edit_cost_item(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- ifcopenshell.api.run("cost.edit_cost_item", model, cost_item=item, attributes={"Name": "Foo"})
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ ifcopenshell.api.cost.edit_cost_item(model, cost_item=item, attributes={"Name": "Foo"})
"""
settings = {"cost_item": cost_item, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py
index 9d1c7a554c..cb265318ac 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_item_quantity.py
@@ -38,16 +38,16 @@ def edit_cost_item_quantity(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# This cost item will have a unit cost of 5 and a volume of 3
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
- quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
+ quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
cost_item=item, ifc_class="IfcQuantityVolume")
- ifcopenshell.api.run("cost.edit_cost_item_quantity", model,
+ ifcopenshell.api.cost.edit_cost_item_quantity(model,
physical_quantity=quantity, "attributes": {"VolumeValue": 3.0})
"""
settings = {"physical_quantity": physical_quantity, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py
index f7392951f6..1c6f42b123 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_schedule.py
@@ -38,8 +38,8 @@ def edit_cost_schedule(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- ifcopenshell.api.run("cost.edit_cost_schedule", model,
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ ifcopenshell.api.cost.edit_cost_schedule(model,
cost_schedule=schedule, attributes={"Name": "Foo"})
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py
index a0e74b85af..f3e4e01acd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value.py
@@ -41,12 +41,12 @@ def edit_cost_value(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# This cost item will have a total cost of 42
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 42.0})
"""
settings = {"cost_value": cost_value, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py
index 1c0b59a79c..9b10e56363 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/edit_cost_value_formula.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.cost
import ifcopenshell.util.cost
import ifcopenshell.util.unit
import ifcopenshell.util.element
@@ -43,11 +43,11 @@ def edit_cost_value_formula(file: ifcopenshell.file, cost_value: ifcopenshell.en
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value_formula", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value_formula(model, cost_value=value,
formula="5000 * 1.19")
"""
usecase = Usecase()
@@ -67,7 +67,7 @@ class Usecase:
def edit_cost_value(self, data, parent=None):
ifc = data.get("ifc", None)
if not ifc:
- ifc = ifcopenshell.api.run("cost.add_cost_value", self.file, parent=parent)
+ ifc = ifcopenshell.api.cost.add_cost_value(self.file, parent=parent)
if "AppliedValue" in data:
if data["AppliedValue"]:
ifc.AppliedValue = self.file.createIfcMonetaryMeasure(data["AppliedValue"])
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py
index 119b22d135..bb9b1bd18d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.cost
import ifcopenshell.util.element
@@ -37,9 +37,9 @@ def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_ins
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- ifcopenshell.api.run("cost.remove_cost_item", model, cost_item=item)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ ifcopenshell.api.cost.remove_cost_item(model, cost_item=item)
"""
settings = {"cost_item": cost_item}
@@ -48,7 +48,7 @@ def remove_cost_item(file: ifcopenshell.file, cost_item: ifcopenshell.entity_ins
if inverse.is_a("IfcRelNests"):
if inverse.RelatingObject == settings["cost_item"]:
for related_object in inverse.RelatedObjects:
- ifcopenshell.api.run("cost.remove_cost_item", file, cost_item=related_object)
+ ifcopenshell.api.cost.remove_cost_item(file, cost_item=related_object)
elif inverse.RelatedObjects == (settings["cost_item"],):
history = inverse.OwnerHistory
file.remove(inverse)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py
index cc7b8c32cb..c9ef89455e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_item_quantity.py
@@ -38,12 +38,12 @@ def remove_cost_item_quantity(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
cost_item=item, ifc_class="IfcQuantityVolume")
# Let's change our mind and delete it
- ifcopenshell.api.run("cost.remove_cost_item", model,
+ ifcopenshell.api.cost.remove_cost_item(model,
cost_item=item, physical_quantity=quantity)
"""
settings = {"cost_item": cost_item, "physical_quantity": physical_quantity}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py
index 01a9c0e0ad..f5591ee9b1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_schedule.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.cost
import ifcopenshell.util.element
@@ -36,9 +36,9 @@ def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.en
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
- ifcopenshell.api.run("cost.remove_cost_schedule", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
+ ifcopenshell.api.cost.remove_cost_schedule(model, cost_schedule=schedule)
"""
settings = {"cost_schedule": cost_schedule}
@@ -46,7 +46,7 @@ def remove_cost_schedule(file: ifcopenshell.file, cost_schedule: ifcopenshell.en
for inverse in file.get_inverse(settings["cost_schedule"]):
if inverse.is_a("IfcRelAssignsToControl"):
[
- ifcopenshell.api.run("cost.remove_cost_item", file, cost_item=related_object)
+ ifcopenshell.api.cost.remove_cost_item(file, cost_item=related_object)
for related_object in inverse.RelatedObjects
if related_object.is_a("IfcCostItem")
]
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py
index 10f4054e93..2c7745d7f9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/remove_cost_value.py
@@ -38,15 +38,15 @@ def remove_cost_value(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# This cost item will have a unit cost of 5 and a volume of 3
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
- ifcopenshell.api.run("cost.remove_cost_value", model, parent=item, cost_value=value)
+ ifcopenshell.api.cost.remove_cost_value(model, parent=item, cost_value=value)
"""
settings = {"parent": parent, "cost_value": cost_value}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py
index a11947c6d8..bb815647fd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.control
def unassign_cost_item_quantity(
@@ -41,30 +41,30 @@ def unassign_cost_item_quantity(
.. code:: python
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
- item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(model)
+ item = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Let's imagine a unit cost of 5.0 per unit volume
- value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item)
- ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
+ value = ifcopenshell.api.cost.add_cost_value(model, parent=item)
+ ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
- slab = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSlab")
+ slab = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSlab")
# Usually the quantity would be automatically calculated via a
# graphical authoring application but let's assign a manual quantity
# for now.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"NetVolume": 42.0})
+ qto = ifcopenshell.api.pset.add_qto(model, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"NetVolume": 42.0})
# Now let's parametrically link the slab's quantity to the cost
# item. If the slab is edited in the future and 42.0 changes, then
# the updated value will also automatically be applied to the cost
# item.
- ifcopenshell.api.run("cost.assign_cost_item_quantity", model,
+ ifcopenshell.api.cost.assign_cost_item_quantity(model,
cost_item=item, products=[slab], prop_name="NetVolume")
# Let's change our mind and remove the parametric connection
- ifcopenshell.api.run("cost.unassign_cost_item_quantity", model,
+ ifcopenshell.api.cost.unassign_cost_item_quantity(model,
cost_item=item, products=[slab])
"""
usecase = Usecase()
@@ -86,8 +86,7 @@ class Usecase:
self.quantities.remove(quantity)
self.settings["cost_item"].CostQuantities = list(self.quantities)
for product in self.settings["products"]:
- ifcopenshell.api.run(
- "control.unassign_control",
+ ifcopenshell.api.control.unassign_control(
self.file,
related_object=product,
relating_control=self.settings["cost_item"],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py b/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py
index a055399ba3..2370e222d4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/add_information.py
@@ -18,6 +18,7 @@
import ifcopenshell
import ifcopenshell.guid
+import ifcopenshell.api.owner
from typing import Optional
@@ -44,14 +45,14 @@ def add_information(
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
+ document = ifcopenshell.api.document.add_information(model)
# A document typically has a unique drawing or document name (which
# follows a coding system depending on the project), as well as a
# title. This should match what is shown on the titleblock or title
# page of the document. At a minimum you'd also want to specify a
# URI location. The location may be on local, or on a CDE, or any
# other platform.
- ifcopenshell.api.run("document.edit_information", model,
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
@@ -64,7 +65,7 @@ def add_information(
file.create_entity(
"IfcRelAssociatesDocument",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
RelatingDocument=information,
RelatedObjects=[parent],
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py b/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py
index 3b96b6d666..0fd2361c8d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/add_reference.py
@@ -46,8 +46,8 @@ def add_reference(file: ifcopenshell.file, information: ifcopenshell.entity_inst
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- ifcopenshell.api.run("document.edit_information", model,
+ document = ifcopenshell.api.document.add_information(model)
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
@@ -55,12 +55,12 @@ def add_reference(file: ifcopenshell.file, information: ifcopenshell.entity_inst
# In this case, we don't specify any more information, and so the
# reference is for the entire document, as opposed to a single page or
# chapter or section.
- reference = ifcopenshell.api.run("document.add_reference", model, information=document)
+ reference = ifcopenshell.api.document.add_reference(model, information=document)
# Alternatively, we can specify a single section, such as by a
# subheading code.
- reference2 = ifcopenshell.api.run("document.add_reference", model, information=document)
- ifcopenshell.api.run("document.edit_reference", model,
+ reference2 = ifcopenshell.api.document.add_reference(model, information=document)
+ ifcopenshell.api.document.edit_reference(model,
reference=reference2, attributes={"Identification": "2.1.15"})
"""
settings = {"information": information}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/assign_document.py b/src/ifcopenshell-python/ifcopenshell/api/document/assign_document.py
index dcd851b897..5627cc1c84 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/assign_document.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/assign_document.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union
@@ -55,15 +55,15 @@ def assign_document(
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- ifcopenshell.api.run("document.edit_information", model,
+ document = ifcopenshell.api.document.add_information(model)
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
- reference = ifcopenshell.api.run("document.add_reference", model, information=document)
+ reference = ifcopenshell.api.document.add_reference(model, information=document)
# Let's imagine storey represents an IfcBuildingStorey for the ground floor
- ifcopenshell.api.run("document.assign_document", model, products=[storey], document=reference)
+ ifcopenshell.api.document.assign_document(model, products=[storey], document=reference)
"""
settings = {
"products": products,
@@ -96,12 +96,12 @@ def assign_document(
return file.create_entity(
"IfcRelAssociatesDocument",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
RelatedObjects=list(products),
RelatingDocument=settings["document"],
)
related_objects = set(rel.RelatedObjects) | products
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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/edit_information.py b/src/ifcopenshell-python/ifcopenshell/api/document/edit_information.py
index 0c9ef1cce0..09d697f7db 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/edit_information.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/edit_information.py
@@ -40,8 +40,8 @@ def edit_information(
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- ifcopenshell.api.run("document.edit_information", model,
+ document = ifcopenshell.api.document.add_information(model)
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/edit_reference.py b/src/ifcopenshell-python/ifcopenshell/api/document/edit_reference.py
index 3ba210cef1..5a00827305 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/edit_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/edit_reference.py
@@ -40,13 +40,13 @@ def edit_reference(
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- ifcopenshell.api.run("document.edit_information", model,
+ document = ifcopenshell.api.document.add_information(model)
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
- reference = ifcopenshell.api.run("document.add_reference", model, information=document)
- ifcopenshell.api.run("document.edit_reference", model,
+ reference = ifcopenshell.api.document.add_reference(model, information=document)
+ ifcopenshell.api.document.edit_reference(model,
reference=reference, attributes={"Identification": "2.1.15"})
"""
settings = {"reference": reference, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/remove_information.py b/src/ifcopenshell-python/ifcopenshell/api/document/remove_information.py
index 6ee66dd386..2ac9e6188b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/remove_information.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/remove_information.py
@@ -18,7 +18,7 @@
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.document
import ifcopenshell.util.element
@@ -37,9 +37,9 @@ def remove_information(file: ifcopenshell.file, information: ifcopenshell.entity
.. code:: python
# Add a document
- document = ifcopenshell.api.run("document.add_information", model)
+ document = ifcopenshell.api.document.add_information(model)
# ... and remove it!
- ifcopenshell.api.run("document.remove_information", model, information=document)
+ ifcopenshell.api.document.remove_information(model, information=document)
"""
if file.schema == "IFC2X3":
@@ -48,11 +48,11 @@ def remove_information(file: ifcopenshell.file, information: ifcopenshell.entity
references = information.HasDocumentReferences
for reference in references:
- ifcopenshell.api.run("document.remove_reference", file, reference=reference)
+ ifcopenshell.api.document.remove_reference(file, reference=reference)
for rel in information.IsPointer or []:
for info in rel.RelatedDocuments:
- ifcopenshell.api.run("document.remove_information", file, information=info)
+ ifcopenshell.api.document.remove_information(file, information=info)
for rel in information.IsPointedTo or []:
if rel.RelatedDocuments == (information,):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py b/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py
index 42264cdec3..41257229ff 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/remove_reference.py
@@ -34,9 +34,9 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- reference = ifcopenshell.api.run("document.add_reference", model, information=document)
- ifcopenshell.api.run("document.remove_reference", model, reference=reference)
+ document = ifcopenshell.api.document.add_information(model)
+ reference = ifcopenshell.api.document.add_reference(model, information=document)
+ ifcopenshell.api.document.remove_reference(model, reference=reference)
"""
if file.schema == "IFC2X3":
diff --git a/src/ifcopenshell-python/ifcopenshell/api/document/unassign_document.py b/src/ifcopenshell-python/ifcopenshell/api/document/unassign_document.py
index 44c0543501..6de39062f9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/document/unassign_document.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/document/unassign_document.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -41,18 +41,18 @@ def unassign_document(
.. code:: python
- document = ifcopenshell.api.run("document.add_information", model)
- ifcopenshell.api.run("document.edit_information", model,
+ document = ifcopenshell.api.document.add_information(model)
+ ifcopenshell.api.document.edit_information(model,
information=document,
attributes={"Identification": "A-GA-6100", "Name": "Overall Plan",
"Location": "A-GA-6100 - Overall Plan.pdf"})
- reference = ifcopenshell.api.run("document.add_reference", model, information=document)
+ reference = ifcopenshell.api.document.add_reference(model, information=document)
# Let's imagine storey represents an IfcBuildingStorey for the ground floor
- ifcopenshell.api.run("document.assign_document", model, products=[storey], document=reference)
+ ifcopenshell.api.document.assign_document(model, products=[storey], document=reference)
# Now let's change our mind and remove the association
- ifcopenshell.api.run("document.unassign_document", model, products=[storey], document=reference)
+ ifcopenshell.api.document.unassign_document(model, products=[storey], document=reference)
"""
settings = {
"products": products,
@@ -77,7 +77,7 @@ def unassign_document(
related_objects = set(rel.RelatedObjects) - 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py
index e620724727..fcd739ffad 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/assign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"],
},
diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py
index 73ba58a776..1f7356e989 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/edit_text_literal.py
@@ -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 {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py b/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py
index b0f6ad1085..03812040cc 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/drawing/unassign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py
index 0c78866ccc..1883374b97 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py
@@ -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()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py
index 73feca9326..8868b22d10 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_door_representation.py
@@ -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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/assign_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/assign_representation.py
index c89c6fd819..33c012fd3f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/assign_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/assign_representation.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_element.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_element.py
index 87d0149407..89c0c1be19 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_element.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_element.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py
index 9e18ca0f18..571c5212ba 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/create_2pt_wall.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/create_2pt_wall.py
index 74c487b47e..039ecb4e99 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/create_2pt_wall.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/create_2pt_wall.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/edit_object_placement.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/edit_object_placement.py
index c71d803ce7..e0c58c3dea 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/edit_object_placement.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/edit_object_placement.py
@@ -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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/unassign_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/unassign_representation.py
index 8473934821..6396914fb4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/geometry/unassign_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/unassign_representation.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-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})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/add_georeferencing.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/add_georeferencing.py
index e4818b6620..43ccaea2bc 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/georeference/add_georeferencing.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/add_georeferencing.py
@@ -42,7 +42,7 @@ def add_georeferencing(file: ifcopenshell.file, ifc_class: str = "IfcMapConversi
.. code:: python
- ifcopenshell.api.run("georeference.add_georeferencing", model)
+ ifcopenshell.api.georeference.add_georeferencing(model)
"""
if file.schema == "IFC2X3":
if not (project := file.by_type("IfcProject")):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py
index 83a9a4f7dd..93163a4982 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
+import ifcopenshell.api.pset
from typing import Optional, Any
@@ -52,12 +53,12 @@ def edit_georeferencing(
.. code:: python
- ifcopenshell.api.run("georeference.add_georeferencing", model)
+ ifcopenshell.api.georeference.add_georeferencing(model)
# This is the simplest scenario, a defined CRS (GDA2020 / MGA Zone
# 56, typically used in Sydney, Australia) but with no local
# coordinates. This is only recommended for horizontal construction
# projects, not for vertical construction (such as buildings).
- ifcopenshell.api.run("georeference.edit_georeferencing", model,
+ ifcopenshell.api.georeference.edit_georeferencing(model,
projected_crs={"Name": "EPSG:7856"})
# For buildings, it is almost always recommended to specify map
@@ -65,7 +66,7 @@ def edit_georeferencing(
# north. See the diagram in the BlenderBIM Add-on Georeferencing
# documentation for correct calculation of the X Axis Abcissa and
# Ordinate.
- ifcopenshell.api.run("georeference.edit_georeferencing", model,
+ ifcopenshell.api.georeference.edit_georeferencing(model,
projected_crs={"Name": "EPSG:7856"},
coordinate_operation={
"Eastings": 335087.17, # The architect nominates a false origin
diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_true_north.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_true_north.py
index 5fd865befd..acffecb063 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_true_north.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_true_north.py
@@ -44,11 +44,11 @@ def edit_true_north(file: ifcopenshell.file, true_north: Optional[Union[tuple[fl
# Both of these are identical, and indicate that:
# - If project north is up the page, true north is in the top left
# - The building is therefore facing north east
- ifcopenshell.api.run("georeference.edit_true_north", model, true_north=30)
- ifcopenshell.api.run("georeference.edit_true_north", model, true_north=(-0.5, 0.8660254))
+ ifcopenshell.api.georeference.edit_true_north(model, true_north=30)
+ ifcopenshell.api.georeference.edit_true_north(model, true_north=(-0.5, 0.8660254))
# This unsets true north
- ifcopenshell.api.run("georeference.edit_true_north", model, true_north=None)
+ ifcopenshell.api.georeference.edit_true_north(model, true_north=None)
"""
if isinstance(true_north, (float, int)):
x, y = ifcopenshell.util.geolocation.angle2yaxis(true_north)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_wcs.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_wcs.py
index 81f70e54b1..4ab04d7347 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_wcs.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_wcs.py
@@ -58,7 +58,7 @@ def edit_wcs(
.. code:: python
# This is the simplest scenario, resetting the WCS to 0,0,0 with no rotation (recommended)
- ifcopenshell.api.run("georeference.edit_wcs", model)
+ ifcopenshell.api.georeference.edit_wcs(model)
"""
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(file)
if np.isclose(rotation, 0):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/remove_georeferencing.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/remove_georeferencing.py
index 0369587fc5..63d46b840b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/georeference/remove_georeferencing.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/remove_georeferencing.py
@@ -31,9 +31,9 @@ def remove_georeferencing(file: ifcopenshell.file) -> None:
Example:
- ifcopenshell.api.run("georeference.add_georeferencing", model)
+ ifcopenshell.api.georeference.add_georeferencing(model)
# Let's change our mind
- ifcopenshell.api.run("georeference.remove_georeferencing", model)
+ ifcopenshell.api.georeference.remove_georeferencing(model)
"""
if file.schema == "IFC2X3":
project = file.by_type("IfcProject")[0]
diff --git a/src/ifcopenshell-python/ifcopenshell/api/grid/create_axis_curve.py b/src/ifcopenshell-python/ifcopenshell/api/grid/create_axis_curve.py
index abb2848205..a1c5d6f942 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/grid/create_axis_curve.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/grid/create_axis_curve.py
@@ -48,17 +48,17 @@ def create_axis_curve(
.. code:: python
# A pretty standard rectangular grid, with only two axes.
- grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
- axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
+ grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
+ axis_a = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="A", uvw_axes="UAxes", grid=grid)
- axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
+ axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="1", uvw_axes="VAxes", grid=grid)
# Assume you have these Blender objects in your active Blender session
obj1 = bpy.data.objects.get("AxisA")
obj2 = bpy.data.objects.get("Axis1")
- ifcopenshell.api.run("grid.create_axis_curve", model, axis_curve=obj1, grid_axis=axis_a)
- ifcopenshell.api.run("grid.create_axis_curve", model, axis_curve=obj2, grid_axis=axis_1)
+ ifcopenshell.api.grid.create_axis_curve(model, axis_curve=obj1, grid_axis=axis_a)
+ ifcopenshell.api.grid.create_axis_curve(model, axis_curve=obj2, grid_axis=axis_1)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/grid/create_grid_axis.py b/src/ifcopenshell-python/ifcopenshell/api/grid/create_grid_axis.py
index b91d86e259..ecd286dd44 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/grid/create_grid_axis.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/grid/create_grid_axis.py
@@ -68,10 +68,10 @@ def create_grid_axis(
Example:
# A pretty standard rectangular grid, with only two axes.
- grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
- axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
+ grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
+ axis_a = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="A", uvw_axes="UAxes", grid=grid)
- axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
+ axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="1", uvw_axes="VAxes", grid=grid)
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/grid/remove_grid_axis.py b/src/ifcopenshell-python/ifcopenshell/api/grid/remove_grid_axis.py
index 2e3ff1b005..8239ab9614 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/grid/remove_grid_axis.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/grid/remove_grid_axis.py
@@ -30,18 +30,18 @@ def remove_grid_axis(file: ifcopenshell.file, axis: ifcopenshell.entity_instance
Example:
# A pretty standard rectangular grid, with only two axes.
- grid = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcGrid")
- axis_a = ifcopenshell.api.run("grid.create_grid_axis", model,
+ grid = ifcopenshell.api.root.create_entity(model, ifc_class="IfcGrid")
+ axis_a = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="A", uvw_axes="UAxes", grid=grid)
- axis_1 = ifcopenshell.api.run("grid.create_grid_axis", model,
+ axis_1 = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="1", uvw_axes="VAxes", grid=grid)
# Let's create a third so we can remove it later
- axis_2 = ifcopenshell.api.run("grid.create_grid_axis", model,
+ axis_2 = ifcopenshell.api.grid.create_grid_axis(model,
axis_tag="2", uvw_axes="VAxes", grid=grid)
# Let's remove it!
- ifcopenshell.api.run("grid.remove_grid_axis", model, axis=axis_2)
+ ifcopenshell.api.grid.remove_grid_axis(model, axis=axis_2)
"""
axis_curve = axis.AxisCurve
if len(file.get_inverse(axis_curve)) == 1:
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/add_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/add_group.py
index bce9ca61bd..eb40127209 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/add_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/add_group.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py
index 0edceb9fa2..64a4f571dc 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/edit_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/edit_group.py
index dca5f781f4..a404ef0f88 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/edit_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/edit_group.py
@@ -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}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/remove_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/remove_group.py
index 9097e1e229..3f3987f66a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/remove_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/remove_group.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/unassign_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/unassign_group.py
index 7d181455cc..ee31336eec 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/unassign_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/unassign_group.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/update_group_products.py b/src/ifcopenshell-python/ifcopenshell/api/group/update_group_products.py
index d71f31a2ff..61b3ec7657 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/group/update_group_products.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/group/update_group_products.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
index d09675cabe..a502c7fd56 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py
@@ -41,6 +41,6 @@ def add_layer(file: ifcopenshell.file, name: str = "Unnamed") -> ifcopenshell.en
Example:
- ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL-FULL-DIMS-N")
+ ifcopenshell.api.layer.add_layer(model, name="AI-WALL-FULL-DIMS-N")
"""
return file.create_entity("IfcPresentationLayerAssignment", Name=name)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/assign_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/assign_layer.py
index 9c7cbd4c46..366f1a5728 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/assign_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/assign_layer.py
@@ -46,24 +46,24 @@ def assign_layer(
# Remember, all geometry needs to specify the context it is part of first.
# See ifcopenshell.api.context.add_context for details.
- model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model
)
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Now let's create a layer that contains walls
- layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
+ layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
# And assign our wall representation item (in this example, there is
# only one item) to the layer.
- ifcopenshell.api.run("layer.assign_layer", model, items=[representation.Items[0]], layer=layer)
+ ifcopenshell.api.layer.assign_layer(model, items=[representation.Items[0]], layer=layer)
"""
settings = {
"items": items,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
index 9ef941c82d..edeb22c1de 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py
@@ -36,8 +36,8 @@ def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, att
.. code:: python
- layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
- ifcopenshell.api.run("layer.edit_layer", model,
+ layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
+ ifcopenshell.api.layer.edit_layer(model,
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
"""
settings = {"layer": layer, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
index d576897fd6..6fe38bf9ee 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py
@@ -33,7 +33,7 @@ def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -
.. code:: python
- layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
- ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
+ layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
+ ifcopenshell.api.layer.remove_layer(model, layer=layer)
"""
file.remove(layer)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/layer/unassign_layer.py b/src/ifcopenshell-python/ifcopenshell/api/layer/unassign_layer.py
index 3fde793058..fe4f13793e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/layer/unassign_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/layer/unassign_layer.py
@@ -43,27 +43,27 @@ def unassign_layer(
# Remember, all geometry needs to specify the context it is part of first.
# See ifcopenshell.api.context.add_context for details.
- model = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model
)
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Now let's create a layer that contains walls
- layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
+ layer = ifcopenshell.api.layer.add_layer(model, name="AI-WALL")
# And assign our wall representation item (in this example, there is
# only one item) to the layer.
- ifcopenshell.api.run("layer.assign_layer", model, items=[representation.Items[0]], layer=layer)
+ ifcopenshell.api.layer.assign_layer(model, items=[representation.Items[0]], layer=layer)
# Let's undo it!
- ifcopenshell.api.run("layer.unassign_layer", model, items=[representation.Items[0]], layer=layer)
+ ifcopenshell.api.layer.unassign_layer(model, items=[representation.Items[0]], layer=layer)
"""
settings = {
"items": items,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
index 00af1708e4..919c0274c1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/add_library.py
@@ -58,6 +58,6 @@ def add_library(file: ifcopenshell.file, name: str) -> ifcopenshell.entity_insta
.. code:: python
- ifcopenshell.api.run("library.add_library", model, name="Brickschema")
+ ifcopenshell.api.library.add_library(model, name="Brickschema")
"""
return file.create_entity("IfcLibraryInformation", Name=name)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py
index 626d413b3d..428e0b01d7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/add_reference.py
@@ -43,11 +43,11 @@ def add_reference(file: ifcopenshell.file, library: ifcopenshell.entity_instance
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
# Let's create a reference to a single AHU in our Brickschema dataset
- reference = ifcopenshell.api.run("library.add_reference", model, library=library)
- ifcopenshell.api.run("library.edit_reference", model,
+ reference = ifcopenshell.api.library.add_reference(model, library=library)
+ ifcopenshell.api.library.edit_reference(model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/assign_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/assign_reference.py
index ea9fff9623..40b3a92f56 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/assign_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/assign_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union
@@ -46,19 +46,19 @@ def assign_reference(
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
# Let's create a reference to a single AHU in our Brickschema dataset
- reference = ifcopenshell.api.run("library.add_reference", model, library=library)
- ifcopenshell.api.run("library.edit_reference", model,
+ reference = ifcopenshell.api.library.add_reference(model, library=library)
+ ifcopenshell.api.library.edit_reference(model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
# Let's assume we have an AHU in our model.
- ahu = ifcopenshell.api.run("root.create_entity", model,
+ ahu = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcUnitaryEquipment", predefined_type="AIRHANDLER")
# And now assign the IFC model's AHU with its Brickschema counterpart
- ifcopenshell.api.run("library.assign_reference", model, reference=reference, products=[ahu])
+ ifcopenshell.api.library.assign_reference(model, reference=reference, products=[ahu])
"""
settings = {
"products": products,
@@ -86,12 +86,12 @@ def assign_reference(
return file.create_entity(
"IfcRelAssociatesLibrary",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
RelatedObjects=list(products),
RelatingLibrary=settings["reference"],
)
related_objects = set(rel.RelatedObjects) | products
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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
index fa4e6b5229..b3bc87b1c3 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py
@@ -38,8 +38,8 @@ def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance,
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
- ifcopenshell.api.run("library.edit_library", model, library=library,
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
+ ifcopenshell.api.library.edit_library(model, library=library,
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
index 621dd32271..f3016fd9cf 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py
@@ -38,10 +38,10 @@ def edit_reference(
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
# Let's create a reference to a single AHU in our Brickschema dataset
- reference = ifcopenshell.api.run("library.add_reference", model, library=library)
- ifcopenshell.api.run("library.edit_reference", model,
+ reference = ifcopenshell.api.library.add_reference(model, library=library)
+ ifcopenshell.api.library.edit_reference(model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
"""
settings = {"reference": reference, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py b/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
index 4f5037f4d6..10c24d7c42 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py
@@ -35,8 +35,8 @@ def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instanc
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
- ifcopenshell.api.run("library.remove_library", model, library=library)
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
+ ifcopenshell.api.library.remove_library(model, library=library)
"""
if file.schema != "IFC2X3":
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py
index 59ac1eafaa..779e2d5279 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/remove_reference.py
@@ -35,10 +35,10 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
- reference = ifcopenshell.api.run("library.add_reference", model, library=library)
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
+ reference = ifcopenshell.api.library.add_reference(model, library=library)
# Let's change our mind and remove it.
- ifcopenshell.api.run("library.remove_reference", model, reference=reference)
+ ifcopenshell.api.library.remove_reference(model, reference=reference)
"""
if file.schema != "IFC2X3":
rels = reference.LibraryRefForObjects
diff --git a/src/ifcopenshell-python/ifcopenshell/api/library/unassign_reference.py b/src/ifcopenshell-python/ifcopenshell/api/library/unassign_reference.py
index c2f2837ad0..876a9b86e6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/library/unassign_reference.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/library/unassign_reference.py
@@ -18,7 +18,7 @@
import ifcopenshell
import ifcopenshell.util.element
-import ifcopenshell.api
+import ifcopenshell.api.owner
def unassign_reference(
@@ -41,22 +41,22 @@ def unassign_reference(
.. code:: python
- library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
+ library = ifcopenshell.api.library.add_library(model, name="Brickschema")
# Let's create a reference to a single AHU in our Brickschema dataset
- reference = ifcopenshell.api.run("library.add_reference", model, library=library)
- ifcopenshell.api.run("library.edit_reference", model,
+ reference = ifcopenshell.api.library.add_reference(model, library=library)
+ ifcopenshell.api.library.edit_reference(model,
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
# Let's assume we have an AHU in our model.
- ahu = ifcopenshell.api.run("root.create_entity", model,
+ ahu = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcUnitaryEquipment", predefined_type="AIRHANDLER")
# And now assign the IFC model's AHU with its Brickschema counterpart
- ifcopenshell.api.run("library.assign_reference", model, reference=reference, products=[ahu])
+ ifcopenshell.api.library.assign_reference(model, reference=reference, products=[ahu])
# Let's change our mind and unassign it.
- ifcopenshell.api.run("library.unassign_reference", model, reference=reference, products=[ahu])
+ ifcopenshell.api.library.unassign_reference(model, reference=reference, products=[ahu])
"""
settings = {"reference": reference, "products": products}
@@ -78,7 +78,7 @@ def unassign_reference(
related_objects = set(rel.RelatedObjects) - 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
index d7a8a19ace..046710d557 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py
@@ -54,11 +54,11 @@ def add_constituent(
# and a glass glazing panel. Notice we are assigning to the type
# only, as all occurrences of that type will automatically inherit
# the material.
- window_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWindowType")
+ window_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWindowType")
# First, let's create a constituent set. This will later be assigned
# to our window element.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialConstituentSet")
# Let's create a few materials, it's important to also give them
@@ -66,13 +66,13 @@ def add_constituent(
# like "show me everything made out of aluminium / concrete / steel
# / glass / etc". The IFC specification states a list of categories
# you can use.
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
# Now let's use those materials as two constituents in our set.
- ifcopenshell.api.run("material.add_constituent", model,
+ ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=aluminium)
- ifcopenshell.api.run("material.add_constituent", model,
+ ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=glass)
# Great! Let's assign our material set to our window type.
@@ -80,7 +80,7 @@ def add_constituent(
# our window too, but to keep this example simple, geometry is
# optional and it is enough to say that this window is made out of
# aluminium and glass.
- ifcopenshell.api.run("material.assign_material", model, products=[window_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[window_type], material=material_set)
"""
settings = {"constituent_set": constituent_set, "material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
index c0dc7c8b76..3b33ffa745 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py
@@ -52,11 +52,11 @@ def add_layer(
# gypsum with steel studs inside. Notice we are assigning to
# the type only, as all occurrences of that type will automatically
# inherit the material.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
# First, let's create a material set. This will later be assigned
# to our wall type element.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
# Let's create a few materials, it's important to also give them
@@ -64,21 +64,21 @@ def add_layer(
# like "show me everything made out of aluminium / concrete / steel
# / glass / etc". The IFC specification states a list of categories
# you can use.
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Now let's use those materials as three layers in our set, such
# that the steel studs are sandwiched by the gypsum. Let's imagine
# we're setting the layer thickness in millimeters.
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 92})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 92})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
# Great! Let's assign our material set to our wall type.
- ifcopenshell.api.run("material.assign_material", model, products=[wall_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
"""
settings = {"layer_set": layer_set, "material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
index 52cb4ecfa8..944a835493 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py
@@ -54,11 +54,11 @@ def add_list_item(
# and a glass glazing panel. Notice we are assigning to the type
# only, as all occurrences of that type will automatically inherit
# the material.
- window_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWindowType")
+ window_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWindowType")
# First, let's create a list. This will later be assigned to our
# window element.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialList")
# Let's create a few materials, it's important to also give them
@@ -66,19 +66,19 @@ def add_list_item(
# like "show me everything made out of aluminium / concrete / steel
# / glass / etc". The IFC specification states a list of categories
# you can use.
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
# Now let's use those materials as two items in our list.
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=aluminium)
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=glass)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=aluminium)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=glass)
# Great! Let's assign our material set to our window type.
# We're technically not done here, we might want to add geometry to
# our window too, but to keep this example simple, geometry is
# optional and it is enough to say that this window is made out of
# aluminium and glass.
- ifcopenshell.api.run("material.assign_material", model, products=[window_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[window_type], material=material_set)
"""
settings = {"material_list": material_list, "material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
index ad05948a03..c18b54fbad 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_material.py
@@ -68,15 +68,15 @@ def add_material(
.. code:: python
# Let's create two materials with their respective categories
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete", description="Garage Slab")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel", description="Corten Steel")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete", description="Garage Slab")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel", description="Corten Steel")
# Let's imagine an urban concrete bench which is purely made out of concrete
- concrete_bench = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
+ concrete_bench = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
# Assign the concrete material to that bench. Note that no colour
# "Style" has been specified.
- ifcopenshell.api.run("material.assign_material", model, products=[concrete_bench], material=concrete)
+ ifcopenshell.api.material.assign_material(model, products=[concrete_bench], material=concrete)
"""
settings = {"name": name or "Unnamed", "category": category, "description": description }
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
index 51edd0b2be..7795c73de2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_material_set.py
@@ -76,11 +76,11 @@ def add_material_set(
# gypsum with steel studs inside. Notice we are assigning to
# the type only, as all occurrences of that type will automatically
# inherit the material.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
# First, let's create a material set. This will later be assigned
# to our wall type element.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
# Let's create a few materials, it's important to also give them
@@ -88,21 +88,21 @@ def add_material_set(
# like "show me everything made out of aluminium / concrete / steel
# / glass / etc". The IFC specification states a list of categories
# you can use.
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Now let's use those materials as three layers in our set, such
# that the steel studs are sandwiched by the gypsum. Let's imagine
# we're setting the layer thickness in millimeters.
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 92})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 92})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
# Great! Let's assign our material set to our wall type.
- ifcopenshell.api.run("material.assign_material", model, products=[wall_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
"""
settings = {"name": name or "Unnamed", "set_type": set_type or "IfcMaterialConstituentSet"}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/add_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/add_profile.py
index 3a23dd44a9..0add4abf47 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/add_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/add_profile.py
@@ -61,15 +61,15 @@ def add_profile(
# Let's imagine we have a steel I-beam. Notice we are assigning to
# the type only, as all occurrences of that type will automatically
# inherit the material.
- beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
+ beam_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeamType", name="B1")
# First, let's create a material set. This will later be assigned
# to our beam type element.
- material_set = ifcopenshell.api.run("material.add_profile_set", model,
+ material_set = ifcopenshell.api.material.add_profile_set(model,
name="B1", set_type="IfcMaterialProfileSet")
# Create a steel material.
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create an I-beam profile curve. Notice how we name our profiles
# based on standardised steel profile names.
@@ -81,11 +81,11 @@ def add_profile(
# Define that steel material and cross section as a single profile
# item. If this were a composite beam, we might add multiple profile
# items instead, but this is rarely the case in most construction.
- ifcopenshell.api.run("material.add_profile", model,
+ ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel, profile=hea100)
# Great! Let's assign our material set to our beam type.
- ifcopenshell.api.run("material.assign_material", model, products=[beam_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[beam_type], material=material_set)
"""
settings = {"profile_set": profile_set, "material": material, "profile": profile}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/assign_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/assign_material.py
index 5ddf9c9524..a9c9caf9f9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/assign_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/assign_material.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.material
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.representation
@@ -88,48 +89,48 @@ def assign_material(
.. code:: python
# Let's start with a simple concrete material
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
# Let's imagine a concrete bench made out of a single concrete
# material. Let's assign it to the type.
- bench_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
- ifcopenshell.api.run("material.assign_material", model,
+ bench_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
+ ifcopenshell.api.material.assign_material(model,
products=[bench_type], type="IfcMaterial", material=concrete)
# Let's imagine there are a two occurrences of this bench. It's not
# necessary to assign any material to these benches as they
# automatically inherit the material from the type.
- bench1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
- bench2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
- ifcopenshell.api.run("type.assign_type", model, related_objects=[bench1], relating_type=bench_type)
- ifcopenshell.api.run("type.assign_type", model, related_objects=[bench2], relating_type=bench_type)
+ bench1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
+ bench2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
+ ifcopenshell.api.type.assign_type(model, related_objects=[bench1], relating_type=bench_type)
+ ifcopenshell.api.type.assign_type(model, related_objects=[bench2], relating_type=bench_type)
# If we have a concrete wall, we should use a layer set. Again,
# let's start with a wall type, not occurrences.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
# Even though there is only one layer in our layer set, we still use
# a layer set because it makes it clear that this is a layered
# construction. Let's say it's a 200mm thick concrete layer.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="CON200", set_type="IfcMaterialLayerSet")
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 200})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 200})
# Our wall type now has the layer set assigned to it
- ifcopenshell.api.run("material.assign_material", model,
+ ifcopenshell.api.material.assign_material(model,
products=[wall_type], type="IfcMaterialLayerSet", material=material_set)
# Let's imagine an occurrence of this wall type.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", model, related_objects=[wall], relating_type=wall_type)
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(model, related_objects=[wall], relating_type=wall_type)
# Our wall occurrence needs to have a "set usage" which describes
# how the layers relate to a reference line (typically a 2D line
# representing the extents of the wall). Usages are special since
# they automatically detect the inherited material set from the
# type. You'd write similar code for a profile set.
- ifcopenshell.api.run("material.assign_material", model,
+ ifcopenshell.api.material.assign_material(model,
products=[wall], type="IfcMaterialLayerSetUsage")
# To be complete, let's create the wall's axis and body
@@ -137,13 +138,13 @@ def assign_material(
# line" which determines where layers are extruded from, and the
# body has a thickness of 200mm, same as our total layer set
# thickness.
- axis = ifcopenshell.api.run("geometry.add_axis_representation", model,
+ axis = ifcopenshell.api.geometry.add_axis_representation(model,
context=axis_context, axis=[(0.0, 0.0), (5000.0, 0.0)])
- body = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ body = ifcopenshell.api.geometry.add_wall_representation(model,
context=body_context, length=5000, height=3000, thickness=200)
- ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=axis)
- ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=body)
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.assign_representation(model, product=wall, representation=axis)
+ ifcopenshell.api.geometry.assign_representation(model, product=wall, representation=body)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
"""
usecase = Usecase()
usecase.file = file
@@ -160,7 +161,7 @@ class Usecase:
# NOTE: we always reassign material, even if it might be assigned before
products_to_unassign_material = [p for p in self.products if ifcopenshell.util.element.get_material(p)]
if products_to_unassign_material:
- ifcopenshell.api.run("material.unassign_material", self.file, products=products_to_unassign_material)
+ ifcopenshell.api.material.unassign_material(self.file, products=products_to_unassign_material)
if self.settings["type"] == "IfcMaterial" or (
self.settings["material"] and not self.settings["material"].is_a("IfcMaterial")
@@ -294,7 +295,7 @@ class Usecase:
return self.create_material_association(material)
previous_related_objects = set(rel.RelatedObjects)
rel.RelatedObjects = list(previous_related_objects | self.products)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
return rel
def create_material_association(
@@ -308,7 +309,7 @@ class Usecase:
"IfcRelAssociatesMaterial",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
"RelatedObjects": products,
"RelatingMaterial": relating_material,
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
index d82a296f34..4d478d421a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/assign_profile.py
@@ -43,15 +43,15 @@ def assign_profile(
# Let's imagine we have a steel I-beam. Notice we are assigning to
# the type only, as all occurrences of that type will automatically
# inherit the material.
- beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
+ beam_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeamType", name="B1")
# First, let's create a material set. This will later be assigned
# to our beam type element.
- material_set = ifcopenshell.api.run("material.add_profile_set", model,
+ material_set = ifcopenshell.api.material.add_profile_set(model,
name="B1", set_type="IfcMaterialProfileSet")
# Create a steel material.
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create an I-beam profile curve. Notice how we name our profiles
# based on standardised steel profile names.
@@ -63,22 +63,22 @@ def assign_profile(
# Define that steel material and cross section as a single profile
# item. If this were a composite beam, we might add multiple profile
# items instead, but this is rarely the case in most construction.
- profile_item = ifcopenshell.api.run("material.add_profile", model,
+ profile_item = ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel, profile=hea100)
# Great! Let's assign our material set to our beam type.
- ifcopenshell.api.run("material.assign_material", model, products=[beam_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[beam_type], material=material_set)
# Let's create an occurrence of this beam.
- beam = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeam", name="B1.01")
- ifcopenshell.api.run("material.assign_material", model,
+ beam = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeam", name="B1.01")
+ ifcopenshell.api.material.assign_material(model,
products=[beam], type="IfcMaterialProfileSetUsage")
# Let's give a 1000mm long beam body representation.
- body = ifcopenshell.api.run("geometry.add_profile_representation",
+ body = ifcopenshell.api.geometry.add_profile_representation(
context=body_context, profile=hea100, depth=1000)
- ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=beam)
+ ifcopenshell.api.geometry.assign_representation(model, product=beam, representation=body)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=beam)
# Now let's change the profile to a HEA200 standard profile instead.
# This will automatically change the body representation that we
@@ -87,7 +87,7 @@ def assign_profile(
"IfcIShapeProfileDef", ProfileName="HEA200", ProfileType="AREA",
OverallWidth=200, OverallDepth=190, WebThickness=6.5, FlangeThickness=10, FilletRadius=18,
)
- ifcopenshell.api.run("material.assign_profile", model, material_profile=profile_item, profile=hea200)
+ ifcopenshell.api.material.assign_profile(model, material_profile=profile_item, profile=hea200)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
index 2bb91a4ba7..b98490ef07 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/copy_material.py
@@ -41,10 +41,10 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
.. code:: python
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
# Let's duplicate the concrete material
- concrete_copy = ifcopenshell.api.run("material.copy_material", model, material=concrete)
+ concrete_copy = ifcopenshell.api.material.copy_material(model, material=concrete)
"""
if material.is_a("IfcMaterial"):
return _copy_material_with_inverses(file, material)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
index 129654d902..bd4ac85b7d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_assigned_material.py
@@ -36,8 +36,8 @@ def edit_assigned_material(file: ifcopenshell.file, element: ifcopenshell.entity
.. code:: python
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
- ifcopenshell.api.run("material.edit_assigned_material", model,
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
+ ifcopenshell.api.material.edit_assigned_material(model,
element=concrete, attributes={"Description": "40MPA concrete with broom finish"})
"""
settings = {"element": element, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
index a11a5ed630..eda33d349b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_constituent.py
@@ -44,25 +44,25 @@ def edit_constituent(
.. code:: python
# Let's add two materials
- aluminium1 = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- aluminium2 = ifcopenshell.api.run("material.add_material", model, name="AL02", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium1 = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ aluminium2 = ifcopenshell.api.material.add_material(model, name="AL02", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialConstituentSet")
# Set up two constituents, one for the frame and the other for the glazing.
- framing = ifcopenshell.api.run("material.add_constituent", model,
+ framing = ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=aluminium1)
- glazing = ifcopenshell.api.run("material.add_constituent", model,
+ glazing = ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=glass)
# Let's make sure this constituent refers to the framing of the
# window and uses the second aluminium material instead.
- ifcopenshell.api.run("material.edit_constituent", model,
+ ifcopenshell.api.material.edit_constituent(model,
constituent=framing, attributes={"Name": "Framing"}, material=aluminium2)
- ifcopenshell.api.run("material.edit_constituent", model,
+ ifcopenshell.api.material.edit_constituent(model,
constituent=constituent, attributes={"Name": "Glazing"})
"""
settings = {"constituent": constituent, "attributes": attributes or {}, "material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
index 57d0b04795..d691d6b154 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer.py
@@ -46,22 +46,22 @@ def edit_layer(
# Let's create two materials typically used for steel stud partition
# walls with gypsum lining.
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create a material layer set to contain our layers.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
# Now let's use those materials as three layers in our set, such
# that the steel studs are sandwiched by the gypsum. Let's imagine
# we're setting the layer thickness in millimeters.
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 92})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 92})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 13})
"""
settings = {"layer": layer, "attributes": attributes or {}, "material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
index e05fc02cab..6c581c1374 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_layer_usage.py
@@ -40,39 +40,39 @@ def edit_layer_usage(file: ifcopenshell.file, usage: ifcopenshell.entity_instanc
.. code:: python
# Let's start with a simple concrete material
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
# If we have a concrete wall, we should use a layer set. Again,
# let's start with a wall type, not occurrences.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
# Even though there is only one layer in our layer set, we still use
# a layer set because it makes it clear that this is a layered
# construction. Let's say it's a 200mm thick concrete layer.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="CON200", set_type="IfcMaterialLayerSet")
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": 200})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": 200})
# Our wall type now has the layer set assigned to it
- ifcopenshell.api.run("material.assign_material", model,
+ ifcopenshell.api.material.assign_material(model,
products=[wall_type], type="IfcMaterialLayerSet", material=material_set)
# Let's imagine an occurrence of this wall type.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", model, related_objects=[wall], relating_type=wall_type)
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(model, related_objects=[wall], relating_type=wall_type)
# Our wall occurrence needs to have a "set usage" which describes
# how the layers relate to a reference line (typically a 2D line
# representing the extents of the wall). Usages are special since
# they automatically detect the inherited material set from the
# type. You'd write similar code for a profile set.
- rel = ifcopenshell.api.run("material.assign_material", model,
+ rel = ifcopenshell.api.material.assign_material(model,
products=[wall], type="IfcMaterialLayerSetUsage")
# Let's change the offset from the reference line to be 200mm
# instead of the default of 0mm.
- ifcopenshell.api.run("material.edit_layer_usage", model,
+ ifcopenshell.api.material.edit_layer_usage(model,
usage=rel.RelatingMaterial, attributes={"OffsetFromReferenceLine": 200})
"""
settings = {"usage": usage, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
index e4fe4b3610..17f925997e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile.py
@@ -51,12 +51,12 @@ def edit_profile(
.. code:: python
# Let's create a material set to store our profiles.
- material_set = ifcopenshell.api.run("material.add_profile_set", model,
+ material_set = ifcopenshell.api.material.add_profile_set(model,
name="B1", set_type="IfcMaterialProfileSet")
# Create a couple steel materials.
- steel1 = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
- steel2 = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ steel1 = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
+ steel2 = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create some I-shaped profiles. Notice how we name our profiles based
# on standardised steel profile names.
@@ -72,12 +72,12 @@ def edit_profile(
# Define that steel material and cross section as a single profile
# item. If this were a composite beam, we might add multiple profile
# items instead, but this is rarely the case in most construction.
- profile_item = ifcopenshell.api.run("material.add_profile", model,
+ profile_item = ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel1, profile=hea100)
# Edit our profile item to use a HEA200 profile instead made out of
# another type of steel.
- ifcopenshell.api.run("material.edit_profile", model,
+ ifcopenshell.api.material.edit_profile(model,
profile=profile_item, profile_def=hea200, material=steel2)
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
index 78cb712f02..f9894db5b3 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/edit_profile_usage.py
@@ -47,15 +47,15 @@ def edit_profile_usage(
# Let's imagine we have a steel I-beam. Notice we are assigning to
# the type only, as all occurrences of that type will automatically
# inherit the material.
- beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
+ beam_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeamType", name="B1")
# First, let's create a material set. This will later be assigned
# to our beam type element.
- material_set = ifcopenshell.api.run("material.add_profile_set", model,
+ material_set = ifcopenshell.api.material.add_profile_set(model,
name="B1", set_type="IfcMaterialProfileSet")
# Create a steel material.
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create an I-beam profile curve. Notice how we name our profiles
# based on standardised steel profile names.
@@ -67,27 +67,27 @@ def edit_profile_usage(
# Define that steel material and cross section as a single profile
# item. If this were a composite beam, we might add multiple profile
# items instead, but this is rarely the case in most construction.
- profile_item = ifcopenshell.api.run("material.add_profile", model,
+ profile_item = ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel, profile=hea100)
# Great! Let's assign our material set to our beam type.
- ifcopenshell.api.run("material.assign_material", model, products=[beam_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[beam_type], material=material_set)
# Let's create an occurrence of this beam.
- beam = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeam", name="B1.01")
- rel = ifcopenshell.api.run("material.assign_material", model,
+ beam = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBeam", name="B1.01")
+ rel = ifcopenshell.api.material.assign_material(model,
products=[beam], type="IfcMaterialProfileSetUsage")
# Let's give a 1000mm long beam body representation.
- body = ifcopenshell.api.run("geometry.add_profile_representation",
+ body = ifcopenshell.api.geometry.add_profile_representation(
context=body_context, profile=hea100, depth=1000)
- ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=beam)
+ ifcopenshell.api.geometry.assign_representation(model, product=beam, representation=body)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=beam)
# Let's change the cardinal point to be the top center of the axis
# line. This is represented by the number "8". Consult the IFC
# documentation for all the numbers you can use.
- ifcopenshell.api.run("material.edit_profile_usage", model,
+ ifcopenshell.api.material.edit_profile_usage(model,
usage=rel.RelatingMaterial, attributes={"CardinalPoint": 8})
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
index d28934e77e..7f6bd4d6a9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_constituent.py
@@ -34,22 +34,22 @@ def remove_constituent(file: ifcopenshell.file, constituent: ifcopenshell.entity
.. code:: python
# Create a material set for windows made out of aluminium and glass.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialConstituentSet")
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
# Now let's use those materials as two constituents in our set.
- framing = ifcopenshell.api.run("material.add_constituent", model,
+ framing = ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=aluminium)
- glazing = ifcopenshell.api.run("material.add_constituent", model,
+ glazing = ifcopenshell.api.material.add_constituent(model,
constituent_set=material_set, material=glass)
# Let's remove the glass constituent. Note that we should not remove
# the framing, at this would mean there are no constituents which is
# invalid.
- ifcopenshell.api.run("material.remove_constituent", model, constituent=glazing)
+ ifcopenshell.api.material.remove_constituent(model, constituent=glazing)
"""
settings = {"constituent": constituent}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
index 744a59b65d..8f3a0f9450 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_layer.py
@@ -34,25 +34,25 @@ def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -
.. code:: python
# Create a material set for steel stud partition walls.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialConstituentSet")
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Now let's use those materials as three layers in our set, such
# that the steel studs are sandwiched by the gypsum. Let's imagine
# we're setting the layer thickness in millimeters.
- layer1 = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer1, attributes={"LayerThickness": 13})
- layer2 = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer2, attributes={"LayerThickness": 92})
- layer3 = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer3, attributes={"LayerThickness": 13})
+ layer1 = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer1, attributes={"LayerThickness": 13})
+ layer2 = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer2, attributes={"LayerThickness": 92})
+ layer3 = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer3, attributes={"LayerThickness": 13})
# Let's remove the last layer, such that the wall might be clad only
# one one side such as to line a services riser.
- ifcopenshell.api.run("material.remove_layer", model, layer=layer3)
+ ifcopenshell.api.material.remove_layer(model, layer=layer3)
"""
settings = {"layer": layer}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
index cdcf8d42cd..cd4f2f1cd6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_list_item.py
@@ -41,18 +41,18 @@ def remove_list_item(
.. code:: python
# Create a material list for aluminium windows.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialMaterialList")
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
# Now let's use those materials as two items in our list.
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=aluminium)
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=glass)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=aluminium)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=glass)
# Let's remove the glass
- ifcopenshell.api.run("material.remove_list_item", model, material_list=material_set, material_index=1)
+ ifcopenshell.api.material.remove_list_item(model, material_list=material_set, material_index=1)
"""
settings = {"material_list": material_list, "material_index": material_index}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
index fe75da3039..d9894b0d96 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material.py
@@ -38,10 +38,10 @@ def remove_material(file: ifcopenshell.file, material: ifcopenshell.entity_insta
.. code:: python
# Create a material
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
# ... and remove it
- ifcopenshell.api.run("material.remove_material", model, material=aluminium)
+ ifcopenshell.api.material.remove_material(model, material=aluminium)
"""
settings = {"material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
index d38b1ec03d..30edd7ad9e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_material_set.py
@@ -38,21 +38,21 @@ def remove_material_set(file: ifcopenshell.file, material: ifcopenshell.entity_i
.. code:: python
# Create a material set
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
# Create some materials
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Add some layers
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
# Completely delete the set and all layers. The gypsum and steel
# material still exist, though.
- ifcopenshell.api.run("material.remove_material_set", model, material=material_set)
+ ifcopenshell.api.material.remove_material_set(model, material=material_set)
"""
settings = {"material": material}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py b/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
index 699c265708..61c696d465 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/remove_profile.py
@@ -37,11 +37,11 @@ def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instanc
.. code:: python
# First, let's create a material set.
- material_set = ifcopenshell.api.run("material.add_profile_set", model,
+ material_set = ifcopenshell.api.material.add_profile_set(model,
name="B1", set_type="IfcMaterialProfileSet")
# Create a steel material.
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Create an I-beam profile curve. Notice how we name our profiles
# based on standardised steel profile names.
@@ -51,17 +51,17 @@ def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instanc
)
# Define that steel material and cross section as a single profile item.
- ifcopenshell.api.run("material.add_profile", model,
+ ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel, profile=hea100)
# Imagine a welded square along the length of the profile.
- welded_square = ifcopenshell.api.run("profile.add_arbitrary_profile", model,
+ welded_square = ifcopenshell.api.profile.add_arbitrary_profile(model,
profile=[(.0025, .0025), (.0325, .0025), (.0325, -.0025), (.0025, -.0025), (.0025, .0025)])
- weld_profile = ifcopenshell.api.run("material.add_profile", model,
+ weld_profile = ifcopenshell.api.material.add_profile(model,
profile_set=material_set, material=steel, profile=welded_square)
# Let's remove our welded square.
- ifcopenshell.api.run("material.remove_profile", model, profile=weld_profile)
+ ifcopenshell.api.material.remove_profile(model, profile=weld_profile)
"""
settings = {"profile": profile}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py b/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
index fbe8dd7bd9..0015d3558a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/reorder_set_item.py
@@ -42,19 +42,19 @@ def reorder_set_item(
.. code:: python
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="Window", set_type="IfcMaterialList")
- aluminium = ifcopenshell.api.run("material.add_material", model, name="AL01", category="aluminium")
- glass = ifcopenshell.api.run("material.add_material", model, name="GLZ01", category="glass")
+ aluminium = ifcopenshell.api.material.add_material(model, name="AL01", category="aluminium")
+ glass = ifcopenshell.api.material.add_material(model, name="GLZ01", category="glass")
# Now let's use those materials as two items in our list.
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=aluminium)
- ifcopenshell.api.run("material.add_list_item", model, material_list=material_set, material=glass)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=aluminium)
+ ifcopenshell.api.material.add_list_item(model, material_list=material_set, material=glass)
# Switch the order around, this has no meaning for a list, so this
# is just for fun.
- ifcopenshell.api.run("material.reorder_set_item", model,
+ ifcopenshell.api.material.reorder_set_item(model,
material_set=material_set, old_index=0, new_index=1)
"""
settings = {"material_set": material_set, "old_index": old_index, "new_index": new_index}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py b/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py
index 93a7f11aea..8db2060df0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/material/unassign_material.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -39,17 +39,17 @@ def unassign_material(file: ifcopenshell.file, products: list[ifcopenshell.entit
.. code:: python
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
# Let's imagine a concrete bench made out of concrete.
- bench_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurnitureType")
- ifcopenshell.api.run("material.assign_material", model,
+ bench_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurnitureType")
+ ifcopenshell.api.material.assign_material(model,
products=[bench_type], type="IfcMaterial", material=concrete)
# Let's change our mind and remove the concrete assignment. The
# concrete material still exists, but the bench is no longer made
# out of concrete now.
- ifcopenshell.api.run("material.unassign_material", model, products=[bench_type])
+ ifcopenshell.api.material.unassign_material(model, products=[bench_type])
"""
usecase = Usecase()
usecase.file = file
@@ -127,4 +127,4 @@ class Usecase:
ifcopenshell.util.element.remove_deep2(self.file, history)
continue
rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/nest/assign_object.py b/src/ifcopenshell-python/ifcopenshell/api/nest/assign_object.py
index 227163f467..b1136d4048 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/nest/assign_object.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/nest/assign_object.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union
@@ -92,11 +92,11 @@ def assign_object(
.. code:: python
# Faucets are designed to attach onto a sink through a predrilled hole.
- sink = ifcopenshell.api.run("root.create_entity", model,
+ sink = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcSanitaryTerminal", predefined_type="SINK")
- faucet = ifcopenshell.api.run("root.create_entity", model,
+ faucet = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcValve", predefined_type="FAUCET")
- ifcopenshell.api.run("nest.assign_object", model, related_objects=[faucet], relating_object=sink)
+ ifcopenshell.api.nest.assign_object(model, related_objects=[faucet], relating_object=sink)
"""
settings = {"related_objects": related_objects, "relating_object": relating_object}
@@ -146,7 +146,7 @@ def assign_object(
cur_related_objects = [o for o in nests.RelatedObjects if o not in related_objects_set]
if cur_related_objects:
nests.RelatedObjects = list(cur_related_objects)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": nests})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": nests})
else:
history = nests.OwnerHistory
file.remove(nests)
@@ -160,13 +160,13 @@ def assign_object(
is_nested_by.RelatedObjects = cur_related_objects + [
o for o in related_objects if o not in cur_related_objects_set
]
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": is_nested_by})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": is_nested_by})
else:
is_nested_by = file.create_entity(
"IfcRelNests",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": related_objects,
"RelatingObject": relating_object,
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py b/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
index fec740477b..6e47e330e5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/nest/change_nest.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.nest
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -32,15 +33,10 @@ def change_nest(
related_objects.remove(item)
if related_objects:
nests.RelatedObjects = related_objects
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": nests})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": nests})
else:
history = nests.OwnerHistory
file.remove(nests)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
- ifcopenshell.api.run(
- "nest.assign_object",
- file,
- related_objects=[item],
- relating_object=new_parent,
- )
+ ifcopenshell.api.nest.assign_object(file, related_objects=[item], relating_object=new_parent)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/nest/unassign_object.py b/src/ifcopenshell-python/ifcopenshell/api/nest/unassign_object.py
index bfd5549ad2..c266dfe291 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/nest/unassign_object.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/nest/unassign_object.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -39,15 +39,15 @@ def unassign_object(file: ifcopenshell.file, related_objects: list[ifcopenshell.
.. code:: python
- task = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcTasks")
- subtask1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcTask")
- subtask2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", model, related_objects=[subtask1], relating_object=task)
- ifcopenshell.api.run("nest.assign_object", model, related_objects=[subtask2], relating_object=task)
+ task = ifcopenshell.api.root.create_entity(model, ifc_class="IfcTasks")
+ subtask1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcTask")
+ subtask2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(model, related_objects=[subtask1], relating_object=task)
+ ifcopenshell.api.nest.assign_object(model, related_objects=[subtask2], relating_object=task)
# nothing is returned
- rel = ifcopenshell.api.run("nest.unassign_object", model, related_objects=[subtask1])
+ rel = ifcopenshell.api.nest.unassign_object(model, related_objects=[subtask1])
# nothing is returned, relationship is removed
- ifcopenshell.api.run("nest.unassign_object", model, related_objects=[subtask2])
+ ifcopenshell.api.nest.unassign_object(model, related_objects=[subtask2])
"""
# NOTE: maintain .RelatedObjects order as it has meaning in IFC
@@ -66,7 +66,7 @@ def unassign_object(file: ifcopenshell.file, related_objects: list[ifcopenshell.
cur_related_objects = [o for o in rel.RelatedObjects if o not in related_objects_set]
if cur_related_objects:
rel.RelatedObjects = cur_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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
index ab2794573c..284020a224 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_actor.py
@@ -18,7 +18,7 @@
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
from typing import Literal
@@ -60,15 +60,15 @@ def add_actor(
.. code:: python
# Setup an organisation with a single role
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
# Assign that organisation to a newly created actor
- actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
+ actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
"""
settings = {"actor": actor, "ifc_class": ifc_class or "IfcActor"}
- actor = ifcopenshell.api.run("root.create_entity", file, ifc_class=settings["ifc_class"])
+ actor = ifcopenshell.api.root.create_entity(file, ifc_class=settings["ifc_class"])
actor.TheActor = settings["actor"]
return actor
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
index 32eaf1a7ab..5b03f9f18a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_address.py
@@ -50,19 +50,19 @@ def add_address(
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model)
+ organisation = ifcopenshell.api.owner.add_organisation(model)
# A snail mail address
- postal = ifcopenshell.api.run("owner.add_address", model,
+ postal = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcPostalAddress")
- ifcopenshell.api.run("owner.edit_address", model, address=postal,
+ ifcopenshell.api.owner.edit_address(model, address=postal,
attributes={"Purpose": "OFFICE", "AddressLines": ["42 Wallaby Way"],
"Town": "Sydney", "Region": "NSW", "PostalCode": "2000"})
# A phone or internet address
- telecom = ifcopenshell.api.run("owner.add_address", model,
+ telecom = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcTelecomAddress")
- ifcopenshell.api.run("owner.edit_address", model, address=telecom,
+ ifcopenshell.api.owner.edit_address(model, address=telecom,
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
"WWWHomePageURL": "https://thinkmoult.com"})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
index fd46625ae5..991006be01 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_application.py
@@ -54,7 +54,7 @@ def add_application(
.. code:: python
- application = ifcopenshell.api.run("owner.add_application", model)
+ application = ifcopenshell.api.owner.add_application(model)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_organisation.py
index 354d66f76a..b5c2fae582 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_organisation.py
@@ -41,7 +41,7 @@ def add_organisation(
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
"""
settings = {"identification": identification, "name": name}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
index d408f39b69..30d81ef117 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person.py
@@ -43,7 +43,7 @@ def add_person(
.. code:: python
- ifcopenshell.api.run("owner.add_person", model,
+ ifcopenshell.api.owner.add_person(model,
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py
index cf2bdb6507..6d6a9bdfb7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_person_and_organisation.py
@@ -40,12 +40,12 @@ def add_person_and_organisation(
.. code:: python
- person = ifcopenshell.api.run("owner.add_person", model,
+ person = ifcopenshell.api.owner.add_person(model,
identification="lecorbycorbycorb", family_name="Curbosiar", given_name="Le")
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- ifcopenshell.api.run("owner.add_person_and_organisation", model,
+ ifcopenshell.api.owner.add_person_and_organisation(model,
person=person, organisation=organisation)
"""
settings = {"person": person, "organisation": organisation}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
index 7c73de69a9..f627a07146 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/add_role.py
@@ -42,9 +42,9 @@ def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_insta
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
+ ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
"""
settings = {"assigned_object": assigned_object, "role": role}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
index 7f2e4a863b..dcda100b34 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/assign_actor.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -54,24 +54,24 @@ def assign_actor(
.. code:: python
# We need to procure and install 2 of this particular pump type in our facility.
- pump_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcPumpType")
+ pump_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcPumpType")
# Define who the manufacturer is
- manufacturer = ifcopenshell.api.run("owner.add_organisation", model,
+ manufacturer = ifcopenshell.api.owner.add_organisation(model,
identification="PWP", name="Pumps With Power")
- ifcopenshell.api.run("owner.add_role", model, assigned_object=manufacturer, role="MANUFACTURER")
+ ifcopenshell.api.owner.add_role(model, assigned_object=manufacturer, role="MANUFACTURER")
# To help our facility manager, it's nice to provide contact details
# of the manufacturer so they know how to call when the pump breaks.
- telecom = ifcopenshell.api.run("owner.add_address", model,
+ telecom = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcTelecomAddress")
- ifcopenshell.api.run("owner.edit_address", model, address=telecom,
+ ifcopenshell.api.owner.edit_address(model, address=telecom,
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
"ElectronicMailAddresses": ["contact@example.com"],
"WWWHomePageURL": "https://example.com"})
# Make the manufacturer responsible for that pump type.
- ifcopenshell.api.run("owner.assign_actor", model,
+ ifcopenshell.api.owner.assign_actor(model,
relating_actor=manufacturer, related_object=pump_type)
"""
settings = {
@@ -93,13 +93,13 @@ def assign_actor(
related_objects = list(rel.RelatedObjects)
related_objects.append(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})
else:
rel = file.create_entity(
"IfcRelAssignsToActor",
**{
"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"]],
"RelatingActor": settings["relating_actor"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py b/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py
index fbb35dbc45..669d2cc730 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/create_owner_history.py
@@ -71,16 +71,16 @@ def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_i
# its own fully branded application. In this case, let's use the
# default application which is prepopulated with "IfcOpenShell" as
# the name and version.
- application = ifcopenshell.api.run("owner.add_application", model)
+ application = ifcopenshell.api.owner.add_application(model)
# Let's imagine we run this as an automated QA process in an
# architectural firm. However, the results must be signed off by the
# registered architect who is liable for the project.
- person = ifcopenshell.api.run("owner.add_person", model,
+ person = ifcopenshell.api.owner.add_person(model,
identification="LPARTEE", family_name="Partee", given_name="Leeable")
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- user = ifcopenshell.api.run("owner.add_person_and_organisation", model,
+ user = ifcopenshell.api.owner.add_person_and_organisation(model,
person=person, organisation=organisation)
# Let's configure our owner settings to hardcode always returning
@@ -94,8 +94,8 @@ def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_i
# create_owner_history at all. This is already automatically handled
# by the API when necessary. Under the hood, the API is actually
# running this code on the IfcSpace element:
- # element.OwnerHistory = ifcopenshell.api.run("owner.create_owner_history", model)
- space = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSpace")
+ # element.OwnerHistory = ifcopenshell.api.owner.create_owner_history(model)
+ space = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSpace")
"""
settings = {}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
index 619e806097..799b37462c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_actor.py
@@ -37,16 +37,16 @@ def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, att
.. code:: python
# Setup an organisation with a single role
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation)
- ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "ARCHITECT"})
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation)
+ ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "ARCHITECT"})
# Assign that organisation to a newly created actor
- actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
+ actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
# Edit the description of the attribute.
- ifcopenshell.api.run("actor.edit_actor", model,
+ ifcopenshell.api.actor.edit_actor(model,
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
"""
settings = {"actor": actor, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
index 4f6df196db..43776fa711 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_address.py
@@ -37,16 +37,16 @@ def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance,
.. code:: python
# A snail mail address
- postal = ifcopenshell.api.run("owner.add_address", model,
+ postal = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcPostalAddress")
- ifcopenshell.api.run("owner.edit_address", model, address=postal,
+ ifcopenshell.api.owner.edit_address(model, address=postal,
attributes={"Purpose": "OFFICE", "AddressLines": ["42 Wallaby Way"],
"Town": "Sydney", "Region": "NSW", "PostalCode": "2000"})
# A phone or internet address
- telecom = ifcopenshell.api.run("owner.add_address", model,
+ telecom = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcTelecomAddress")
- ifcopenshell.api.run("owner.edit_address", model, address=telecom,
+ ifcopenshell.api.owner.edit_address(model, address=telecom,
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
"WWWHomePageURL": "https://thinkmoult.com"})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
index f3991918ca..5e92a31e04 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_organisation.py
@@ -36,9 +36,9 @@ def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects With Ballpens")
- ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
+ ifcopenshell.api.owner.edit_organisation(model, organisation=organisation,
attributes={"name": "Architects Without Ballpens"})
"""
settings = {"organisation": organisation, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
index 1a66068727..0e4bd15293 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_person.py
@@ -36,9 +36,9 @@ def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, a
.. code:: python
- person = ifcopenshell.api.run("owner.add_person", model,
+ person = ifcopenshell.api.owner.add_person(model,
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
- ifcopenshell.api.run("owner.edit_person", model, person=person,
+ ifcopenshell.api.owner.edit_person(model, person=person,
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
"""
settings = {"person": person, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
index 034a685d5d..885d4b9b9b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/edit_role.py
@@ -36,14 +36,14 @@ def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attri
.. code:: python
- person = ifcopenshell.api.run("owner.add_person", model,
+ person = ifcopenshell.api.owner.add_person(model,
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
# By default, the role is an architect
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=person)
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=person)
# But Bob is not an architect
- ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
+ ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
"""
settings = {"role": role, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
index d11f18657d..026808b7d2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_actor.py
@@ -33,16 +33,16 @@ def remove_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance) -
.. code:: python
# Setup an organisation with a single role
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation)
- ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "ARCHITECT"})
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation)
+ ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "ARCHITECT"})
# Assign that organisation to a newly created actor
- actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
+ actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
# Actually we need ballpens on this project
- ifcopenshell.api.run("owner.remove_actor", model, actor=actor)
+ ifcopenshell.api.owner.remove_actor(model, actor=actor)
"""
settings = {"actor": actor}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
index 31fc19b675..0d8ff96ff9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_address.py
@@ -33,12 +33,12 @@ def remove_address(file: ifcopenshell.file, address: ifcopenshell.entity_instanc
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model)
- address = ifcopenshell.api.run("owner.add_address", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model)
+ address = ifcopenshell.api.owner.add_address(model,
assigned_object=organisation, ifc_class="IfcPostalAddress")
# Change our mind and delete it
- ifcopenshell.api.run("owner.remove_address", model, address=address)
+ ifcopenshell.api.owner.remove_address(model, address=address)
"""
settings = {"address": address}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
index f441205925..c744d2f97f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_application.py
@@ -33,8 +33,8 @@ def remove_application(file: ifcopenshell.file, application: ifcopenshell.entity
.. code:: python
- application = ifcopenshell.api.run("owner.add_application", model)
- ifcopenshell.api.run("owner.remove_address", model, application=application)
+ application = ifcopenshell.api.owner.add_application(model)
+ ifcopenshell.api.owner.remove_address(model, application=application)
"""
settings = {"application": application}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
index c1652a1fce..fbc25adcbe 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_organisation.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.owner
def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance) -> None:
@@ -34,18 +35,18 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- ifcopenshell.api.run("owner.remove_organisation", model, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(model, organisation=organisation)
"""
settings = {"organisation": organisation}
for role in settings["organisation"].Roles or []:
if len(file.get_inverse(role)) == 1:
- ifcopenshell.api.run("owner.remove_role", file, role=role)
+ ifcopenshell.api.owner.remove_role(file, role=role)
for address in settings["organisation"].Addresses or []:
if len(file.get_inverse(address)) == 1:
- ifcopenshell.api.run("owner.remove_address", file, address=address)
+ ifcopenshell.api.owner.remove_address(file, address=address)
for inverse in file.get_inverse(settings["organisation"]):
if inverse.is_a("IfcOrganizationRelationship"):
if inverse.RelatingOrganization == settings["organisation"]:
@@ -56,13 +57,13 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
if inverse.Editors == (settings["organisation"],):
inverse.Editors = None
elif inverse.is_a("IfcPersonAndOrganization"):
- ifcopenshell.api.run("owner.remove_person_and_organisation", file, person_and_organisation=inverse)
+ ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
elif inverse.is_a("IfcActor"):
- ifcopenshell.api.run("root.remove_product", file, product=inverse)
+ ifcopenshell.api.root.remove_product(file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship") and not inverse.is_a("IfcOrganizationRelationship"):
if inverse.RelatedResourceObjects == (settings["organisation"],):
file.remove(inverse)
elif inverse.is_a("IfcApplication"):
- ifcopenshell.api.run("owner.remove_application", file, application=inverse)
+ ifcopenshell.api.owner.remove_application(file, application=inverse)
file.remove(settings["organisation"])
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
index 5ce265cae2..a4f4d64f1f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.owner
def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance) -> None:
@@ -36,18 +37,18 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
.. code:: python
- ifcopenshell.api.run("owner.add_person", model,
+ ifcopenshell.api.owner.add_person(model,
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
- ifcopenshell.api.run("owner.remove_person", model, person=person)
+ ifcopenshell.api.owner.remove_person(model, person=person)
"""
settings = {"person": person}
for role in settings["person"].Roles or []:
if len(file.get_inverse(role)) == 1:
- ifcopenshell.api.run("owner.remove_role", file, role=role)
+ ifcopenshell.api.owner.remove_role(file, role=role)
for address in settings["person"].Addresses or []:
if len(file.get_inverse(address)) == 1:
- ifcopenshell.api.run("owner.remove_address", file, address=address)
+ ifcopenshell.api.owner.remove_address(file, address=address)
for inverse in file.get_inverse(settings["person"]):
if inverse.is_a("IfcWorkControl"):
if inverse.Creators == (settings["person"],):
@@ -56,14 +57,14 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
if inverse.ResponsiblePersons == (settings["person"],):
# in IFC2X3 ResponsiblePersons is not optional and without it IfcInventory is not valid
if file.schema == "IFC2X3":
- ifcopenshell.api.run("root.remove_product", file, product=inverse)
+ ifcopenshell.api.root.remove_product(file, product=inverse)
elif inverse.is_a("IfcDocumentInformation"):
if inverse.Editors == (settings["person"],):
inverse.Editors = None
elif inverse.is_a("IfcPersonAndOrganization"):
- ifcopenshell.api.run("owner.remove_person_and_organisation", file, person_and_organisation=inverse)
+ ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
elif inverse.is_a("IfcActor"):
- ifcopenshell.api.run("root.remove_product", file, product=inverse)
+ ifcopenshell.api.root.remove_product(file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship"):
if inverse.RelatedResourceObjects == (settings["person"],):
file.remove(inverse)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
index 1311dfa642..95f137f046 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_person_and_organisation.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
def remove_person_and_organisation(
@@ -36,15 +36,15 @@ def remove_person_and_organisation(
.. code:: python
- person = ifcopenshell.api.run("owner.add_person", model,
+ person = ifcopenshell.api.owner.add_person(model,
identification="lecorbycorbycorb", family_name="Curbosiar", given_name="Le")
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- user = ifcopenshell.api.run("owner.add_person_and_organisation", model,
+ user = ifcopenshell.api.owner.add_person_and_organisation(model,
person=person, organisation=organisation)
- ifcopenshell.api.run("owner.remove_person_and_organisation", model, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(model, person_and_organisation=user)
"""
settings = {"person_and_organisation": person_and_organisation}
@@ -53,7 +53,7 @@ def remove_person_and_organisation(
if inverse.Editors == (settings["person_and_organisation"],):
inverse.Editors = None
elif inverse.is_a("IfcActor"):
- ifcopenshell.api.run("root.remove_product", file, product=inverse)
+ ifcopenshell.api.root.remove_product(file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship"):
if inverse.RelatedResourceObjects == (settings["person_and_organisation"],):
file.remove(inverse)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
index 7ecfa8847e..07c2d36a9a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/remove_role.py
@@ -33,12 +33,12 @@ def remove_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance) ->
.. code:: python
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="AWB", name="Architects Without Ballpens")
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
# After running this, the organisation will have no role again
- ifcopenshell.api.run("owner.remove_role", model, role=role)
+ ifcopenshell.api.owner.remove_role(model, role=role)
"""
settings = {"role": role}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py b/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
index 38f63688a6..e161e046e2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/unassign_actor.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -40,19 +40,19 @@ def unassign_actor(
.. code:: python
# We need to procure and install 2 of this particular pump type in our facility.
- pump_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcPumpType")
+ pump_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcPumpType")
# Define who the manufacturer is
- manufacturer = ifcopenshell.api.run("owner.add_organisation", model,
+ manufacturer = ifcopenshell.api.owner.add_organisation(model,
identification="PWP", name="Pumps With Power")
- ifcopenshell.api.run("owner.add_role", model, assigned_object=manufacturer, role="MANUFACTURER")
+ ifcopenshell.api.owner.add_role(model, assigned_object=manufacturer, role="MANUFACTURER")
# Make the manufacturer responsible for that pump type.
- ifcopenshell.api.run("owner.assign_actor", model,
+ ifcopenshell.api.owner.assign_actor(model,
relating_actor=manufacturer, related_object=pump_type)
# Undo the assignment
- ifcopenshell.api.run("owner.unassign_actor", model,
+ ifcopenshell.api.owner.unassign_actor(model,
relating_actor=manufacturer, related_object=pump_type)
"""
settings = {
@@ -72,4 +72,4 @@ def unassign_actor(
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})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/owner/update_owner_history.py b/src/ifcopenshell-python/ifcopenshell/api/owner/update_owner_history.py
index 95a356ef2f..c7cb3b719d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/owner/update_owner_history.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/owner/update_owner_history.py
@@ -51,13 +51,13 @@ def update_owner_history(
# create_owner_history at all. This is already automatically handled
# by the API when necessary. Under the hood, the API is actually
# running this code on the IfcSpace element:
- # element.OwnerHistory = ifcopenshell.api.run("owner.create_owner_history", model)
- space = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSpace")
+ # element.OwnerHistory = ifcopenshell.api.owner.create_owner_history(model)
+ space = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSpace")
# Any edits we make will have ownership tracking automatically
# applied. There is no need to run any owner.update_owner_history
# API calls either.
- ifcopenshell.api.run("attribute.edit_attributes", model, product=space, attributes={"Name": "Lobby"})
+ ifcopenshell.api.attribute.edit_attributes(model, product=space, attributes={"Name": "Lobby"})
"""
settings = {"element": element}
@@ -74,7 +74,7 @@ def update_owner_history(
# 1 IfcRoot IfcOwnerHistory
owner_history = element[1]
if not owner_history:
- owner_history = ifcopenshell.api.run("owner.create_owner_history", file)
+ owner_history = ifcopenshell.api.owner.create_owner_history(file)
element[1] = owner_history
return owner_history
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
index 8c432c9626..08892a555b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile.py
@@ -47,7 +47,7 @@ def add_arbitrary_profile(
# A 10mm by 100mm rectangle, such that might be used as a wooden
# skirting board or kick plate.
- square = ifcopenshell.api.run("profile.add_arbitrary_profile", model,
+ square = ifcopenshell.api.profile.add_arbitrary_profile(model,
profile=[(0., 0.), (.01, 0.), (.01, .1), (0., .1), (0., 0.)],
name="SK01 Profile")
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
index 52287aee7c..8412d40e23 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_arbitrary_profile_with_voids.py
@@ -56,7 +56,7 @@ def add_arbitrary_profile_with_voids(
.. code:: python
# A 400mm by 400mm square with a 200mm by 200mm hole in it.
- square_with_hole = ifcopenshell.api.run("profile.add_arbitrary_profile_with_voids", model,
+ square_with_hole = ifcopenshell.api.profile.add_arbitrary_profile_with_voids(model,
outer_profile=[(0., 0.), (.4, 0.), (.4, .4), (0., .4), (0., 0.)],
inner_profiles=[[(0.1, 0.1), (0.3, 0.1), (0.3, 0.3), (0.1, 0.3), (0.1, 0.1)]],
name="SK01 Hole Profile")
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
index abb205ba5e..3a23507e54 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/add_parameterized_profile.py
@@ -38,7 +38,7 @@ def add_parameterized_profile(file: ifcopenshell.file, ifc_class: str) -> ifcope
.. code:: python
- circle = ifcopenshell.api.run("profile.add_parameterized_profile", model,
+ circle = ifcopenshell.api.profile.add_parameterized_profile(model,
ifc_class="IfcCircleProfileDef")
circle.Radius = 1.
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
index bfcb9da595..b1fda065f0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/edit_profile.py
@@ -36,11 +36,11 @@ def edit_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instance,
.. code:: python
- circle = ifcopenshell.api.run("profile.add_parameterized_profile", model,
+ circle = ifcopenshell.api.profile.add_parameterized_profile(model,
ifc_class="IfcCircleProfileDef")
circle = 1.
- ifcopenshell.api.run("profile.edit_profile", model,
+ ifcopenshell.api.profile.edit_profile(model,
profile=circle, attributes={"ProfileName": "1000mm Dia"})
"""
settings = {"profile": profile, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py b/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
index f20cfc89fc..aeadafdb5a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/profile/remove_profile.py
@@ -32,10 +32,10 @@ def remove_profile(file: ifcopenshell.file, profile: ifcopenshell.entity_instanc
.. code:: python
- circle = ifcopenshell.api.run("profile.add_parameterized_profile", model,
+ circle = ifcopenshell.api.profile.add_parameterized_profile(model,
ifc_class="IfcCircleProfileDef")
circle = 1.
- ifcopenshell.api.run("profile.remove_profile", model, profile=circle)
+ ifcopenshell.api.profile.remove_profile(model, profile=circle)
"""
settings = {"profile": profile}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
index df1a3246c6..08bd45197f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py
@@ -17,7 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.type
+import ifcopenshell.api.project
+import ifcopenshell.api.context
import ifcopenshell.api.owner.settings
import ifcopenshell.util.element
from typing import Optional, Any, Union
@@ -63,37 +65,37 @@ def append_asset(
.. code:: python
# Programmatically generate a library. You could do this visually too.
- library = ifcopenshell.api.run("project.create_file")
- root = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject", name="Demo Library")
- context = ifcopenshell.api.run("root.create_entity", library,
+ library = ifcopenshell.api.project.create_file()
+ root = ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject", name="Demo Library")
+ context = ifcopenshell.api.root.create_entity(library,
ifc_class="IfcProjectLibrary", name="Demo Library")
- ifcopenshell.api.run("project.assign_declaration", library, definitions=[context], relating_context=root)
+ ifcopenshell.api.project.assign_declaration(library, definitions=[context], relating_context=root)
# Assign units for our example library
- unit = ifcopenshell.api.run("unit.add_si_unit", library,
+ unit = ifcopenshell.api.unit.add_si_unit(library,
unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
- ifcopenshell.api.run("unit.assign_unit", library, units=[unit])
+ ifcopenshell.api.unit.assign_unit(library, units=[unit])
# Let's create a single asset of a 200mm thick concrete wall
- wall_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType", name="WAL01")
- concrete = ifcopenshell.api.run("material.add_material", usecase.file, name="CON", category="concrete")
- rel = ifcopenshell.api.run("material.assign_material", library,
+ wall_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType", name="WAL01")
+ concrete = ifcopenshell.api.material.add_material(usecase.file, name="CON", category="concrete")
+ rel = ifcopenshell.api.material.assign_material(library,
products=[wall_type], type="IfcMaterialLayerSet")
- layer = ifcopenshell.api.run("material.add_layer", library,
+ layer = ifcopenshell.api.material.add_layer(library,
layer_set=rel.RelatingMaterial, material=concrete)
layer.Name = "Structure"
layer.LayerThickness = 200
# Mark our wall type as a reusable asset in our library.
- ifcopenshell.api.run("project.assign_declaration", library,
+ ifcopenshell.api.project.assign_declaration(library,
definitions=[wall_type], relating_context=context)
# Let's imagine we're starting a new project
- model = ifcopenshell.api.run("project.create_file")
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject", name="Test")
+ model = ifcopenshell.api.project.create_file()
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject", name="Test")
# Now we can easily append our wall type from our libary
- wall_type = ifcopenshell.api.run("project.append_asset", model, library=library, element=wall_type)
+ wall_type = ifcopenshell.api.project.append_asset(model, library=library, element=wall_type)
Example of adding multiple assets and avoiding duplicated inverses:
@@ -106,8 +108,7 @@ def append_asset(
reuse_identities = dict()
for element in ifcopenshell.util.selector.filter_elements(model, "IfcWindow"):
- ifcopenshell.api.run(
- "project.append_asset",
+ ifcopenshell.api.project.append_asset(
model, library=library,
element=wall_type
reuse_identities=reuse_identities
@@ -208,15 +209,13 @@ class Usecase:
element_type = ifcopenshell.util.element.get_type(self.settings["element"])
if element_type:
ifcopenshell.api.owner.settings.factory_reset()
- new_type = ifcopenshell.api.run(
- "project.append_asset",
+ new_type = ifcopenshell.api.project.append_asset(
self.file,
library=self.settings["library"],
element=element_type,
reuse_identities=self.reuse_identities,
)
- ifcopenshell.api.run(
- "type.assign_type",
+ ifcopenshell.api.type.assign_type(
self.file,
should_run_listeners=False,
related_objects=[element],
@@ -357,16 +356,14 @@ class Usecase:
parent = self.get_equivalent_existing_context(added_context.ParentContext)
if not parent:
parent = self.create_equivalent_context(added_context.ParentContext)
- return ifcopenshell.api.run(
- "context.add_context",
+ return ifcopenshell.api.context.add_context(
self.file,
parent=parent,
context_type=added_context.ContextType,
context_identifier=added_context.ContextIdentifier,
target_view=added_context.TargetView,
)
- return ifcopenshell.api.run(
- "context.add_context",
+ return ifcopenshell.api.context.add_context(
self.file,
context_type=added_context.ContextType,
context_identifier=added_context.ContextIdentifier,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py b/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py
index bffef52943..ab8d97bea9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/project/assign_declaration.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union
@@ -55,31 +55,31 @@ def assign_declaration(
.. code:: python
# Programmatically generate a library. You could do this visually too.
- library = ifcopenshell.api.run("project.create_file")
- root = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject", name="Demo Library")
- context = ifcopenshell.api.run("root.create_entity", library,
+ library = ifcopenshell.api.project.create_file()
+ root = ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject", name="Demo Library")
+ context = ifcopenshell.api.root.create_entity(library,
ifc_class="IfcProjectLibrary", name="Demo Library")
# It's necessary to say our library is part of our project.
- ifcopenshell.api.run("project.assign_declaration", library, definitions=[context], relating_context=root)
+ ifcopenshell.api.project.assign_declaration(library, definitions=[context], relating_context=root)
# Assign units for our example library
- unit = ifcopenshell.api.run("unit.add_si_unit", library,
+ unit = ifcopenshell.api.unit.add_si_unit(library,
unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
- ifcopenshell.api.run("unit.assign_unit", library, units=[unit])
+ ifcopenshell.api.unit.assign_unit(library, units=[unit])
# Let's create a single asset of a 200mm thick concrete wall
- wall_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType", name="WAL01")
- concrete = ifcopenshell.api.run("material.add_material", file, name="CON", category="concrete")
- rel = ifcopenshell.api.run("material.assign_material", library,
+ wall_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType", name="WAL01")
+ concrete = ifcopenshell.api.material.add_material(file, name="CON", category="concrete")
+ rel = ifcopenshell.api.material.assign_material(library,
products=[wall_type], type="IfcMaterialLayerSet")
- layer = ifcopenshell.api.run("material.add_layer", library,
+ layer = ifcopenshell.api.material.add_layer(library,
layer_set=rel.RelatingMaterial, material=concrete)
layer.Name = "Structure"
layer.LayerThickness = 200
# Mark our wall type as a reusable asset in our library.
- ifcopenshell.api.run("project.assign_declaration", library,
+ ifcopenshell.api.project.assign_declaration(library,
definitions=[wall_type], relating_context=context)
# All done, just for fun let's save our asset library to disk for later use.
@@ -123,7 +123,7 @@ def assign_declaration(
related_definitions = set(has_context.RelatedDefinitions) - set(objects_with_contexts)
if related_definitions:
has_context.RelatedDefinitions = list(related_definitions)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": has_context})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": has_context})
else:
history = has_context.OwnerHistory
file.remove(has_context)
@@ -133,13 +133,13 @@ def assign_declaration(
declares = next(iter(all_declares), None)
if declares:
declares.RelatedDefinitions = list(set(declares.RelatedDefinitions) | set(objects_to_change))
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": declares})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": declares})
else:
declares = file.create_entity(
"IfcRelDeclares",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedDefinitions": list(objects_to_change),
"RelatingContext": relating_context,
},
diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py b/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py
index 6db9e87c01..5ce3592749 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/project/create_file.py
@@ -43,11 +43,11 @@ def create_file(version: str = "IFC4") -> ifcopenshell.file:
.. code:: python
# Start a new model.
- model = ifcopenshell.api.run("project.create_file")
+ model = ifcopenshell.api.project.create_file()
# It's currently a blank model, so typically the first thing we do
# is create a project in it.
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject", name="Test")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject", name="Test")
# ... and off we go!
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/unassign_declaration.py b/src/ifcopenshell-python/ifcopenshell/api/project/unassign_declaration.py
index 38a0ae4e25..7d012b09af 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/project/unassign_declaration.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/project/unassign_declaration.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -44,16 +44,16 @@ def unassign_declaration(
.. code:: python
# Programmatically generate a library. You could do this visually too.
- library = ifcopenshell.api.run("project.create_file")
- root = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject", name="Demo Library")
- context = ifcopenshell.api.run("root.create_entity", library,
+ library = ifcopenshell.api.project.create_file()
+ root = ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject", name="Demo Library")
+ context = ifcopenshell.api.root.create_entity(library,
ifc_class="IfcProjectLibrary", name="Demo Library")
# It's necessary to say our library is part of our project.
- ifcopenshell.api.run("project.assign_declaration", library, definitions=[context], relating_context=root)
+ ifcopenshell.api.project.assign_declaration(library, definitions=[context], relating_context=root)
# Remove the library from our project
- ifcopenshell.api.run("project.unassign_declaration", library, definitions=[context], relating_context=root)
+ ifcopenshell.api.project.unassign_declaration(library, definitions=[context], relating_context=root)
"""
settings = {
"definitions": definitions,
@@ -67,7 +67,7 @@ def unassign_declaration(
related_definitions = set(rel.RelatedDefinitions) - definitions
if related_definitions:
rel.RelatedDefinitions = list(related_definitions)
- 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py
index 349a1fa85f..1d4f650029 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -72,15 +72,15 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
.. code:: python
# Let's imagine we have a new wall type.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
# Note that this only creates and assigns an empty property set. We
# still need to add properties into the property set. Having blank
# property sets are invalid.
- pset = ifcopenshell.api.run("pset.add_pset", model, product=wall_type, name="Pset_WallCommon")
+ pset = ifcopenshell.api.pset.add_pset(model, product=wall_type, name="Pset_WallCommon")
# Add a fire rating property standardised by buildingSMART.
- ifcopenshell.api.run("pset.edit_pset", model, pset=pset, properties={"FireRating": "2HR"})
+ ifcopenshell.api.pset.edit_pset(model, pset=pset, properties={"FireRating": "2HR"})
"""
settings = {"product": product, "name": name}
@@ -93,7 +93,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
"IfcPropertySet",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"Name": settings["name"],
}
)
@@ -101,7 +101,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
"IfcRelDefinesByProperties",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [settings["product"]],
"RelatingPropertyDefinition": pset,
}
@@ -116,7 +116,7 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
"IfcPropertySet",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"Name": settings["name"],
}
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/add_qto.py b/src/ifcopenshell-python/ifcopenshell/api/pset/add_qto.py
index f7bcd66d2f..15646fe9c7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset/add_qto.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset/add_qto.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -64,17 +64,17 @@ def add_qto(file: ifcopenshell.file, product: ifcopenshell.entity_instance, name
.. code:: python
# Let's imagine we have a new wall.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Note that this only creates and assigns an empty quantity set. We
# still need to add quantities into the property set. Having blank
# quantity sets are invalid.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=wall_type, name="Qto_WallBaseQuantities")
+ qto = ifcopenshell.api.pset.add_qto(model, product=wall_type, name="Qto_WallBaseQuantities")
# Add a side area property standardised by buildingSMART. This
# allows quantity take-off to occur, even though no geometry has
# even been modelled!
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"NetSideArea": 4.2})
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"NetSideArea": 4.2})
"""
usecase = Usecase()
usecase.file = file
@@ -97,7 +97,7 @@ class Usecase:
"IfcRelDefinesByProperties",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
"RelatedObjects": [self.settings["product"]],
"RelatingPropertyDefinition": qto,
}
@@ -117,6 +117,6 @@ class Usecase:
return self.file.create_entity(
"IfcElementQuantity",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
Name=self.settings["name"],
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py
index 12ee1206cf..797f0afba3 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_pset.py
@@ -90,10 +90,10 @@ def edit_pset(
.. code:: python
# Let's imagine we have a new wall type.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
# This is a standard buildingSMART property set.
- pset = ifcopenshell.api.run("pset.add_pset", model, product=wall_type, name="Pset_WallCommon")
+ pset = ifcopenshell.api.pset.add_pset(model, product=wall_type, name="Pset_WallCommon")
# In this scenario, we don't specify any pset_template because it is
# part of the built-in buildingSMART templates, and so the
@@ -101,47 +101,47 @@ def edit_pset(
# transmittance value will automatically be an
# IfcThermalTransmittanceMeasure. Neither of these properties exist
# yet, so they will be created.
- ifcopenshell.api.run("pset.edit_pset", model,
+ ifcopenshell.api.pset.edit_pset(model,
pset=pset, properties={"FireRating": "2HR", "ThermalTransmittance": 42.3})
# We can edit existing properties. In this case, "FireRating" is
# edited from "2HR" to "1HR". Combustible is new, and will be added.
# The existing "ThermalTransmittance" property will be left
# unchanged.
- ifcopenshell.api.run("pset.edit_pset", model,
+ ifcopenshell.api.pset.edit_pset(model,
pset=pset, properties={"FireRating": "1HR", "Combustible": False})
# Setting to None will change the value but not delete the property.
- ifcopenshell.api.run("pset.edit_pset", model, pset=pset, properties={"Combustible": None})
+ ifcopenshell.api.pset.edit_pset(model, pset=pset, properties={"Combustible": None})
# If you actually want to delete the property, enable purging.
- ifcopenshell.api.run("pset.edit_pset", model, pset=pset,
+ ifcopenshell.api.pset.edit_pset(model, pset=pset,
properties={"Combustible": None}, should_purge=True)
# What if we wanted to manage our own properties? Let's create our
# own "Company Standard" property set templates. Notice how we
# prefix our property set with "Foo_", if our company name was "Foo"
# this would make sense.
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="Foo_bar")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="Foo_bar")
# Let's imagine we want all model authors to specify two properties,
# one being a length measurement and another being a boolean.
- prop1 = ifcopenshell.api.run("pset_template.add_prop_template", model,
+ prop1 = ifcopenshell.api.pset_template.add_prop_template(model,
pset_template=template, name="DemoA", primary_measure_type="IfcLengthMeasure")
- prop2 = ifcopenshell.api.run("pset_template.add_prop_template", model,
+ prop2 = ifcopenshell.api.pset_template.add_prop_template(model,
pset_template=template, name="DemoB", primary_measure_type="IfcBoolean")
# Now we can use our property set template to add our properties,
# and the data types will always match our template.
- pset = ifcopenshell.api.run("pset.add_pset", model, product=wall_type, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", model,
+ pset = ifcopenshell.api.pset.add_pset(model, product=wall_type, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(model,
pset=pset, properties={"DemoA": 42.3, "DemoB": True}, pset_template=template)
# Here's a third scenario where we want to add arbitrary properties
# that are not standardised by anything, not even our own custom
# templates.
- pset = ifcopenshell.api.run("pset.add_pset", model, product=wall_type, name="Custom_Pset")
- ifcopenshell.api.run("pset.edit_pset", model,
+ pset = ifcopenshell.api.pset.add_pset(model, product=wall_type, name="Custom_Pset")
+ ifcopenshell.api.pset.edit_pset(model,
pset=pset, properties={
# Basic Python data types are mapped to a sensible default
"SomeLabel": "Foo",
@@ -152,7 +152,7 @@ def edit_pset(
# Editing existing properties will retain their current data types
# if possible. So this will still be a length measure.
- ifcopenshell.api.run("pset.edit_pset", model, pset=pset, properties={"ExplicitLength": 12.3})
+ ifcopenshell.api.pset.edit_pset(model, pset=pset, properties={"ExplicitLength": 12.3})
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py
index f23dc593b2..fce082fd86 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py
@@ -66,45 +66,45 @@ def edit_qto(
.. code:: python
# Let's imagine we have a new wall type.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# This is a standard buildingSMART property set.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=wall, name="Qto_WallBaseQuantities")
+ qto = ifcopenshell.api.pset.add_qto(model, product=wall, name="Qto_WallBaseQuantities")
# In this scenario, we don't specify any pset_template because it is
# part of the built-in buildingSMART templates, and so the Length
# will automatically be an IfcLengthMeasure, and the NetVolume will
# automatically be an IfcVolumeMeasure. Neither of these properties
# exist yet, so they will be created.
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"Length": 12, "NetVolume": 7.2})
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"Length": 12, "NetVolume": 7.2})
# Setting to None will delete the quantity.
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"Length": None})
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"Length": None})
# What if we wanted to manage our own properties? Let's create our
# own "Company Standard" property set templates. Notice how we
# prefix our property set with "Foo_", if our company name was "Foo"
# this would make sense. In this example, we say that our template
# only applies to walls and is for quantities.
- template = ifcopenshell.api.run("pset_template.add_pset_template", model,
+ template = ifcopenshell.api.pset_template.add_pset_template(model,
name="Foo_Wall", template_type="QTO_OCCURRENCEDRIVEN", applicable_entity="IfcWall")
# Let's imagine we want all model authors to specify a length
# measurement for the portion of a wall that is overhanging.
- prop = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template,
+ prop = ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template,
name="OverhangLength", template_type="Q_LENGTH", primary_measure_type="IfcLengthMeasure")
# Now we can use our property set template to add our properties,
# and the data types will always match our template.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=wall, name="Foo_Wall")
- ifcopenshell.api.run("pset.edit_qto", model,
+ qto = ifcopenshell.api.pset.add_qto(model, product=wall, name="Foo_Wall")
+ ifcopenshell.api.pset.edit_qto(model,
qto=qto, properties={"OverhangLength": 42.3}, pset_template=template)
# Here's a third scenario where we want to add arbitrary quantities
# that are not standardised by anything, not even our own custom
# templates.
- qto = ifcopenshell.api.run("pset.add_qto", model, product=wall, name="Custom_Qto")
- ifcopenshell.api.run("pset.edit_qto", model,
+ qto = ifcopenshell.api.pset.add_qto(model, product=wall, name="Custom_Qto")
+ ifcopenshell.api.pset.edit_qto(model,
qto=qto, properties={
"SomeLength": model.createIfcLengthMeasure(42.3),
"SomeArea": model.createIfcAreaMeasure(21.0)
@@ -112,7 +112,7 @@ def edit_qto(
# Editing existing quantities will retain their current data types
# if possible. So this will still be a length measure.
- ifcopenshell.api.run("pset.edit_qto", model, qto=qto, properties={"SomeLength": 12.3})
+ ifcopenshell.api.pset.edit_qto(model, qto=qto, properties={"SomeLength": 12.3})
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py
index b6302bb4b1..d6636e9f09 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py
@@ -39,11 +39,11 @@ def remove_pset(
.. code:: python
# Let's imagine we have a new wall type with a property set.
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType")
- pset = ifcopenshell.api.run("pset.add_pset", model, product=wall_type, name="Pset_WallCommon")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
+ pset = ifcopenshell.api.pset.add_pset(model, product=wall_type, name="Pset_WallCommon")
# Remove it!
- ifcopenshell.api.run("pset.remove_pset", model, product=wall_type, pset=pset)
+ ifcopenshell.api.pset.remove_pset(model, product=wall_type, pset=pset)
"""
settings = {"product": product, "pset": pset}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_prop_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_prop_template.py
index 360b086cab..5d5bca3510 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_prop_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_prop_template.py
@@ -73,15 +73,15 @@ def add_prop_template(
.. code:: python
# Create a simple template that may be applied to all types
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="ABC_RiskFactors")
# Here's one example property
- ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template,
+ ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template,
name="HighVoltage", description="Whether there is a risk of high voltage.",
primary_measure_type="IfcBoolean")
# Here's another
- ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template,
+ ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template,
name="ChemicalType", description="The class of chemical spillage.",
primary_measure_type="IfcLabel")
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_pset_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_pset_template.py
index e382a3a34d..fc1b9a4265 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_pset_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/add_pset_template.py
@@ -90,12 +90,12 @@ def add_pset_template(
.. code:: python
# Create a simple template that may be applied to all types
- ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
+ ifcopenshell.api.pset_template.add_pset_template(model, name="ABC_RiskFactors")
# Note that we aren't finished yet. Our property set template
# doesn't have any properties in it. Let's add a minimum of one
# property.
- ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template,
+ ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template,
name="HighVoltage", description="Whether there is a risk of high voltage.",
primary_measure_type="IfcBoolean")
"""
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_prop_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_prop_template.py
index 5c738bf8e0..e5429b948c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_prop_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_prop_template.py
@@ -38,13 +38,13 @@ def edit_prop_template(
.. code:: python
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="ABC_RiskFactors")
# Here's a property with just default values.
- prop = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template)
+ prop = ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template)
# Let's edit it to give the actual values we need.
- ifcopenshell.api.run("pset_template.edit_prop_template", model,
+ ifcopenshell.api.pset_template.edit_prop_template(model,
prop_template=prop, attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLengthMeasure"})
"""
if enum_values := attributes.get("Enumerators", None):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_pset_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_pset_template.py
index 6e71d182a5..1682fa150d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_pset_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/edit_pset_template.py
@@ -39,10 +39,10 @@ def edit_pset_template(
.. code:: python
# Whoops! We named it with a buildingSMART reserved "Pset_" prefix!
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="Pset_RiskFactors")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="Pset_RiskFactors")
# Let's fix it to prefix with our company code instead.
- ifcopenshell.api.run("pset_template.edit_pset_template", model,
+ ifcopenshell.api.pset_template.edit_pset_template(model,
pset_template=template, attributes={"Name": "ABC_RiskFactors"})
"""
settings = {"pset_template": pset_template, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_prop_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_prop_template.py
index d5986af02c..99558cf6e8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_prop_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_prop_template.py
@@ -35,14 +35,14 @@ def remove_prop_template(file: ifcopenshell.file, prop_template: ifcopenshell.en
.. code:: python
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="ABC_RiskFactors")
# Here's two propertes with just default values.
- prop1 = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template)
- prop2 = ifcopenshell.api.run("pset_template.add_prop_template", model, pset_template=template)
+ prop1 = ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template)
+ prop2 = ifcopenshell.api.pset_template.add_prop_template(model, pset_template=template)
# Let's remove the second one.
- ifcopenshell.api.run("pset_template.remove_prop_template", model, prop_template=prop2)
+ ifcopenshell.api.pset_template.remove_prop_template(model, prop_template=prop2)
"""
settings = {"prop_template": prop_template}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_pset_template.py b/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_pset_template.py
index a1731ac5e1..de321ea6fd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_pset_template.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/pset_template/remove_pset_template.py
@@ -35,10 +35,10 @@ def remove_pset_template(file: ifcopenshell.file, pset_template: ifcopenshell.en
.. code:: python
# Create a template.
- template = ifcopenshell.api.run("pset_template.add_pset_template", model, name="ABC_RiskFactors")
+ template = ifcopenshell.api.pset_template.add_pset_template(model, name="ABC_RiskFactors")
# Let's remove the template.
- ifcopenshell.api.run("pset_template.remove_pset_template", model, pset_template=template)
+ ifcopenshell.api.pset_template.remove_pset_template(model, pset_template=template)
"""
settings = {"pset_template": pset_template}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py
index dd60840349..41aa8bec8c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py
@@ -16,7 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.nest
+import ifcopenshell.api.project
from typing import Optional
@@ -69,10 +71,10 @@ def add_resource(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- ifcopenshell.api.run("resource.add_resource", model, parent_resource=crew, ifc_class="IfcLaborResource")
+ ifcopenshell.api.resource.add_resource(model, parent_resource=crew, ifc_class="IfcLaborResource")
"""
settings = {
"parent_resource": parent_resource,
@@ -81,8 +83,7 @@ def add_resource(
"predefined_type": predefined_type,
}
- resource = ifcopenshell.api.run(
- "root.create_entity",
+ resource = ifcopenshell.api.root.create_entity(
file,
ifc_class=settings["ifc_class"],
predefined_type=settings["predefined_type"],
@@ -91,18 +92,10 @@ def add_resource(
# TODO: this is an ambiguity by buildingSMART: Can we nest an IfcCrewResource under an IfcCrewResource ?
# https://forums.buildingsmart.org/t/what-are-allowed-to-be-root-level-construction-resources/3550
if settings["parent_resource"]:
- ifcopenshell.api.run(
- "nest.assign_object",
- file,
- related_objects=[resource],
- relating_object=settings["parent_resource"],
+ ifcopenshell.api.nest.assign_object(
+ file, related_objects=[resource], relating_object=settings["parent_resource"]
)
elif file.schema != "IFC2X3":
context = file.by_type("IfcContext")[0]
- ifcopenshell.api.run(
- "project.assign_declaration",
- file,
- definitions=[resource],
- relating_context=context,
- )
+ ifcopenshell.api.project.assign_declaration(file, definitions=[resource], relating_context=context)
return resource
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_quantity.py
index 72eb582af6..b445c1d1ad 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_quantity.py
@@ -51,18 +51,18 @@ def add_resource_quantity(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
+ quantity = ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Store the time used in hours
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=quantity, attributes={"TimeValue": 8.0})
"""
settings = {"resource": resource, "ifc_class": ifc_class}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py
index c353888656..7c9e5179ec 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource_time.py
@@ -37,23 +37,23 @@ def add_resource_time(file: ifcopenshell.file, resource: ifcopenshell.entity_ins
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
+ quantity = ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Store the unit time used in hours
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=quantity, attributes={"TimeValue": 8.0})
# Let's imagine we've used the resource for 2 days.
- time = ifcopenshell.api.run("resource.add_resource_time", model, resource=labour)
- ifcopenshell.api.run("resource.edit_resource_time", model,
+ time = ifcopenshell.api.resource.add_resource_time(model, resource=labour)
+ ifcopenshell.api.resource.edit_resource_time(model,
resource_time=time, attributes={"ScheduleWork": "PT16H"})
"""
resource_time = file.create_entity("IfcResourceTime")
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/assign_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/assign_resource.py
index e86d02cc4f..626082bce2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/assign_resource.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/assign_resource.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -54,33 +54,33 @@ def assign_resource(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some a tower crane to our crew.
- crane = ifcopenshell.api.run("resource.add_resource", model,
+ crane = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcConstructionEquipmentResource", name="Tower Crane 01")
# Our tower crane will be placed via this physical product.
- product = ifcopenshell.api.run("root.create_entity", model,
+ product = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcBuildingElementProxy", predefined_type="CRANE")
# Let's place our crane at some X, Y coordinates.
matrix = numpy.eye(4)
matrix[0][3], matrix[1][3] = 3.0, 4.0
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=crane, matrix=matrix)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=crane, matrix=matrix)
# Let's assign our crane to the resource. The crane now represents
# the resource.
- ifcopenshell.api.run("resource.assign_resource", model, relating_resource=crane, related_object=product)
+ ifcopenshell.api.resource.assign_resource(model, relating_resource=crane, related_object=product)
# Setup an organisation actor who will operate the crane
- organisation = ifcopenshell.api.run("owner.add_organisation", model,
+ organisation = ifcopenshell.api.owner.add_organisation(model,
identification="UCO", name="Unionised Crane Operators Pty Ltd")
- role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="CREW")
- actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
+ role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="CREW")
+ actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
# This means that UCO is now our crane operator.
- ifcopenshell.api.run("resource.assign_resource", model, relating_resource=crane, related_object=actor)
+ ifcopenshell.api.resource.assign_resource(model, relating_resource=crane, related_object=actor)
"""
settings = {
"relating_resource": relating_resource,
@@ -103,13 +103,13 @@ def assign_resource(
related_objects = list(resource_of.RelatedObjects)
related_objects.append(settings["related_object"])
resource_of.RelatedObjects = related_objects
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": resource_of})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": resource_of})
else:
resource_of = file.create_entity(
"IfcRelAssignsToResource",
**{
"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"]],
"RelatingResource": settings["relating_resource"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py b/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py
index 29b80283c0..426a0fc1eb 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py
@@ -16,8 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import math
-import ifcopenshell.api
+import ifcopenshell.api.resource
import ifcopenshell.util.constraint
import ifcopenshell.util.date
import ifcopenshell.util.element
@@ -62,9 +61,5 @@ def calculate_resource_work(file: ifcopenshell.file, resource: ifcopenshell.enti
if not amount_worked:
return
if not resource.Usage:
- ifcopenshell.api.run(
- "resource.add_resource_time",
- file,
- resource=resource,
- )
+ ifcopenshell.api.resource.add_resource_time(file, resource=resource)
resource.Usage.ScheduleWork = amount_worked
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource.py
index 6ec4ed0b1a..b5bb899ead 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource.py
@@ -37,10 +37,10 @@ def edit_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_instanc
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Change the name of the resource to "Zone A Crew"
- ifcopenshell.api.run("resource.edit_resource", model, resource=resource, attributes={"Name": "Foo"})
+ ifcopenshell.api.resource.edit_resource(model, resource=resource, attributes={"Name": "Foo"})
"""
settings = {"resource": resource, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_quantity.py
index 3a4e754c6b..af8f55f94f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_quantity.py
@@ -39,18 +39,18 @@ def edit_resource_quantity(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- ifcopenshell.api.run("resource.add_resource_quantity", model,
+ ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Store the time used in hours
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=time, attributes={"TimeValue": 8.0})
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py
index ad03df0908..687fe0490d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/edit_resource_time.py
@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import datetime
import ifcopenshell
+import ifcopenshell.api.sequence
from typing import Any
@@ -41,23 +41,23 @@ def edit_resource_time(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- ifcopenshell.api.run("resource.add_resource_quantity", model,
+ ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Store the unit time used in hours
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=time, attributes={"TimeValue": 8.0})
# Let's imagine we've used the resource for 2 days.
- time = ifcopenshell.api.run("resource.add_resource_time", model, resource=labour)
- ifcopenshell.api.run("resource.edit_resource_time", model,
+ time = ifcopenshell.api.resource.add_resource_time(model, resource=labour)
+ ifcopenshell.api.resource.edit_resource_time(model,
resource_time=time, attributes={"ScheduleWork": "P16H"})
"""
usecase = Usecase()
@@ -94,7 +94,7 @@ class Usecase:
):
task = ifcopenshell.util.resource.get_task_assignments(self.resource)
if task:
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
def get_resource(self):
return [e for e in self.file.get_inverse(self.settings["resource_time"]) if e.is_a("IfcResource")][0]
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource.py
index bf5c46e6f7..b75e1f908c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.resource
import ifcopenshell.util.element
@@ -29,10 +29,10 @@ def remove_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_insta
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Fire our crew
- ifcopenshell.api.run("resource.remove_resource", model, resource=crew)
+ ifcopenshell.api.resource.remove_resource(model, resource=crew)
"""
settings = {"resource": resource}
@@ -41,11 +41,7 @@ def remove_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_insta
if inverse.is_a("IfcRelNests"):
if inverse.RelatingObject == settings["resource"]:
for related_object in inverse.RelatedObjects:
- ifcopenshell.api.run(
- "resource.remove_resource",
- file,
- resource=related_object,
- )
+ ifcopenshell.api.resource.remove_resource(file, resource=related_object)
history = inverse.OwnerHistory
file.remove(inverse)
if history:
@@ -63,11 +59,8 @@ def remove_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_insta
elif inverse.is_a("IfcRelAssignsToResource"):
if inverse.RelatingResource == settings["resource"]:
for related_object in inverse.RelatedObjects:
- ifcopenshell.api.run(
- "resource.unassign_resource",
- file,
- related_object=related_object,
- resource=settings["resource"],
+ ifcopenshell.api.resource.unassign_resource(
+ file, related_object=related_object, relating_resource=settings["resource"]
)
elif inverse.RelatedObjects == tuple(settings["resource"]):
history = inverse.OwnerHistory
@@ -78,11 +71,7 @@ def remove_resource(file: ifcopenshell.file, resource: ifcopenshell.entity_insta
if usage := getattr(settings["resource"], "Usage", None):
file.remove(usage)
if settings["resource"].BaseQuantity:
- ifcopenshell.api.run(
- "resource.remove_resource_quantity",
- file,
- resource=settings["resource"],
- )
+ ifcopenshell.api.resource.remove_resource_quantity(file, resource=settings["resource"])
history = settings["resource"].OwnerHistory
file.remove(settings["resource"])
if history:
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource_quantity.py
index 9b173f689f..e7c91e6073 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource_quantity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/remove_resource_quantity.py
@@ -27,19 +27,19 @@ def remove_resource_quantity(file: ifcopenshell.file, resource: ifcopenshell.ent
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- ifcopenshell.api.run("resource.add_resource_quantity", model,
+ ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Let's say we only want to store the resource but no quantities,
# let's clean up our mess and remove the quantity.
- ifcopenshell.api.run("resource.remove_resource_quantity", model, resource=labour)
+ ifcopenshell.api.resource.remove_resource_quantity(model, resource=labour)
"""
settings = {"resource": resource}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/unassign_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/unassign_resource.py
index 93a8caff93..76ea9e6d5b 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/resource/unassign_resource.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/resource/unassign_resource.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -41,23 +41,23 @@ def unassign_resource(
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some a tower crane to our crew.
- crane = ifcopenshell.api.run("resource.add_resource", model,
+ crane = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcConstructionEquipmentResource", name="Tower Crane 01")
# Our tower crane will be placed via this physical product.
- product = ifcopenshell.api.run("root.create_entity", model,
+ product = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcBuildingElementProxy", predefined_type="CRANE")
# Let's assign our crane to the resource. The crane now represents
# the resource.
- ifcopenshell.api.run("resource.assign_resource", model,
+ ifcopenshell.api.resource.assign_resource(model,
relating_resource=crane, related_object=product)
# Undo it.
- ifcopenshell.api.run("resource.unassign_resource", model,
+ ifcopenshell.api.resource.unassign_resource(model,
relating_resource=crane, related_object=product)
"""
settings = {
@@ -77,4 +77,4 @@ def unassign_resource(
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})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py b/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py
index 1c49f178fd..a55c711e53 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py
@@ -17,7 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
+import ifcopenshell.api.geometry
import ifcopenshell.util.system
import ifcopenshell.util.element
import ifcopenshell.util.placement
@@ -60,10 +62,10 @@ def copy_class(file: ifcopenshell.file, product: ifcopenshell.entity_instance) -
.. code:: python
# We have a wall
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# And now we have two
- wall_copy = ifcopenshell.api.run("root.copy_class", model, product=wall)
+ wall_copy = ifcopenshell.api.root.copy_class(model, product=wall)
"""
usecase = Usecase()
usecase.file = file
@@ -104,7 +106,7 @@ class Usecase:
ports = [inverse.RelatingPort]
if not ports:
continue
- new_ports = [ifcopenshell.api.run("root.copy_class", self.file, product=p) for p in ports]
+ new_ports = [ifcopenshell.api.root.copy_class(self.file, product=p) for p in ports]
inverse = ifcopenshell.util.element.copy(self.file, inverse)
if inverse.is_a("IfcRelNests"):
@@ -115,11 +117,10 @@ class Usecase:
inverse.RelatingPort = new_ports[0]
for port in new_ports:
- ifcopenshell.api.run("system.unassign_port", self.file, element=from_element, port=port)
- ifcopenshell.api.run("system.disconnect_port", self.file, port=port)
+ ifcopenshell.api.system.unassign_port(self.file, element=from_element, port=port)
+ ifcopenshell.api.system.disconnect_port(self.file, port=port)
matrix = ifcopenshell.util.placement.get_local_placement(port.ObjectPlacement)
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=port,
matrix=matrix,
@@ -136,7 +137,7 @@ class Usecase:
opening = inverse.RelatedOpeningElement
# We don't copy filled openings, since there is no guarantee the filling is also copied
if not opening.is_a("IfcOpeningElement") or not opening.HasFillings:
- new_opening = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
+ new_opening = ifcopenshell.api.root.copy_class(self.file, product=opening)
new_opening.VoidsElements[0].RelatingBuildingElement = to_element
if new_opening.ObjectPlacement and new_opening.ObjectPlacement.is_a("IfcLocalPlacement"):
if to_element.ObjectPlacement:
diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py
index c11f0d4d67..a31dc4c00a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/root/create_entity.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Optional
@@ -58,16 +58,16 @@ def create_entity(
.. code:: python
# We have a project.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
# We have a building.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
# We have a wall.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# We have a wall type.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
"""
usecase = Usecase()
usecase.file = file
@@ -85,7 +85,7 @@ class Usecase:
self.settings["ifc_class"],
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
}
)
element.Name = self.settings["name"] or None
diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/reassign_class.py b/src/ifcopenshell-python/ifcopenshell/api/root/reassign_class.py
index 9bf29a0306..3326f0b123 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/root/reassign_class.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/root/reassign_class.py
@@ -61,10 +61,10 @@ def reassign_class(
.. code:: python
# We have a wall.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Oh, did I say wall? I meant slab.
- slab = ifcopenshell.api.run("root.reassign_class", model, product=wall, ifc_class="IfcSlab")
+ slab = ifcopenshell.api.root.reassign_class(model, product=wall, ifc_class="IfcSlab")
# Warning: this will crash since wall doesn't exist any more.
print(wall) # Kaboom.
diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py
index b78e75c801..77fbc4264d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/root/remove_product.py
@@ -16,7 +16,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.type
+import ifcopenshell.api.grid
+import ifcopenshell.api.void
+import ifcopenshell.api.root
+import ifcopenshell.api.pset
+import ifcopenshell.api.boundary
+import ifcopenshell.api.material
+import ifcopenshell.api.geometry
import ifcopenshell.util.element
@@ -50,10 +57,10 @@ def remove_product(file: ifcopenshell.file, product: ifcopenshell.entity_instanc
.. code:: python
# We have a wall.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# No we don't.
- ifcopenshell.api.run("root.remove_product", model, product=wall)
+ ifcopenshell.api.root.remove_product(model, product=wall)
"""
settings = {"product": product}
@@ -79,26 +86,19 @@ def remove_product(file: ifcopenshell.file, product: ifcopenshell.entity_instanc
for pset in psets:
if file.get_total_inverses(pset) != 1:
continue
- ifcopenshell.api.run(
- "pset.remove_pset",
- file,
- product=settings["product"],
- pset=pset,
- )
+ ifcopenshell.api.pset.remove_pset(file, product=settings["product"], pset=pset)
for representation in representations:
- ifcopenshell.api.run(
- "geometry.unassign_representation",
- file,
- **{"product": settings["product"], "representation": representation}
+ ifcopenshell.api.geometry.unassign_representation(
+ file, product=settings["product"], representation=representation
)
- ifcopenshell.api.run("geometry.remove_representation", file, **{"representation": representation})
+ ifcopenshell.api.geometry.remove_representation(file, **{"representation": representation})
for opening in getattr(settings["product"], "HasOpenings", []) or []:
- ifcopenshell.api.run("void.remove_opening", file, opening=opening.RelatedOpeningElement)
+ ifcopenshell.api.void.remove_opening(file, opening=opening.RelatedOpeningElement)
if settings["product"].is_a("IfcGrid"):
for axis in settings["product"].UAxes + settings["product"].VAxes + (settings["product"].WAxes or ()):
- ifcopenshell.api.run("grid.remove_grid_axis", file, axis=axis)
+ ifcopenshell.api.grid.remove_grid_axis(file, axis=axis)
def element_exists(element_id):
try:
@@ -114,21 +114,18 @@ def remove_product(file: ifcopenshell.file, product: ifcopenshell.entity_instanc
except:
continue
if inverse.is_a("IfcRelDefinesByProperties"):
- ifcopenshell.api.run(
- "pset.remove_pset",
- file,
- product=settings["product"],
- pset=inverse.RelatingPropertyDefinition,
+ ifcopenshell.api.pset.remove_pset(
+ file, product=settings["product"], pset=inverse.RelatingPropertyDefinition
)
elif inverse.is_a("IfcRelAssociatesMaterial"):
- ifcopenshell.api.run("material.unassign_material", file, products=[settings["product"]])
+ ifcopenshell.api.material.unassign_material(file, products=[settings["product"]])
elif inverse.is_a("IfcRelDefinesByType"):
if inverse.RelatingType == settings["product"]:
- ifcopenshell.api.run("type.unassign_type", file, related_objects=inverse.RelatedObjects)
+ ifcopenshell.api.type.unassign_type(file, related_objects=inverse.RelatedObjects)
else:
- ifcopenshell.api.run("type.unassign_type", file, related_objects=[settings["product"]])
+ ifcopenshell.api.type.unassign_type(file, related_objects=[settings["product"]])
elif inverse.is_a("IfcRelSpaceBoundary"):
- ifcopenshell.api.run("boundary.remove_boundary", file, boundary=inverse)
+ ifcopenshell.api.boundary.remove_boundary(file, boundary=inverse)
elif inverse.is_a("IfcRelFillsElement"):
history = inverse.OwnerHistory
file.remove(inverse)
@@ -149,7 +146,7 @@ def remove_product(file: ifcopenshell.file, product: ifcopenshell.entity_instanc
inverse_id = inverse.id()
for subelement in inverse.RelatedObjects:
if subelement.is_a("IfcDistributionPort"):
- ifcopenshell.api.run("root.remove_product", file, product=subelement)
+ ifcopenshell.api.root.remove_product(file, product=subelement)
# IfcRelNests could have been already deleted after removing one of the products
if element_exists(inverse_id):
history = inverse.OwnerHistory
@@ -185,7 +182,7 @@ def remove_product(file: ifcopenshell.file, product: ifcopenshell.entity_instanc
ifcopenshell.util.element.remove_deep2(file, history)
elif inverse.is_a("IfcRelConnectsPortToElement"):
if inverse.RelatedElement == settings["product"]:
- ifcopenshell.api.run("root.remove_product", file, product=inverse.RelatingPort)
+ ifcopenshell.api.root.remove_product(file, product=inverse.RelatingPort)
elif inverse.RelatingPort == settings["product"]:
history = inverse.OwnerHistory
file.remove(inverse)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py
index 152c74439b..1e1b4fe2df 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py
@@ -16,7 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.nest
+import ifcopenshell.api.owner
import ifcopenshell
import ifcopenshell.guid
from typing import Optional
@@ -91,50 +93,50 @@ def add_task(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Add a root task to represent the design milestones, and major
# project phases.
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Milestones", identification="A")
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Design", identification="B")
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's start creating our work breakdown structure.
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Early Works", identification="C1")
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Substructure", identification="C2")
- superstructure = ifcopenshell.api.run("sequence.add_task", model,
+ superstructure = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Superstructure", identification="C3")
# Notice how the leaf task is the actual activity
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
parent_task=superstructure, name="Ground Floor FRP", identification="C3.1")
# Let's imagine we are digitising an operations and maintenance
# manual for the mechanical discipline.
- maintenance = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Mechanical Maintenance")
+ maintenance = ifcopenshell.api.sequence.add_work_schedule(model, name="Mechanical Maintenance")
# Imagine we have to clean the condenser coils for a chiller every
# month. Like the schedule above, to keep things simple we won't
# show scheduling times and calendars. This root task represents the
# overall maintenance task.
- cleaning = ifcopenshell.api.run("sequence.add_task", model,
+ cleaning = ifcopenshell.api.sequence.add_task(model,
work_schedule=maintenance, name="Condenser coil cleaning")
# These subtasks represent the punch list of maintenance tasks.
- ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="1",
+ ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="1",
description="Prior to work, wear safety shoes, gloves, and goggles.")
- ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="2",
+ ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="2",
description="Prepare jet pump, screwdriver, hose clamp, and control panel door key.")
- ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
+ ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
description="Switch OFF the chiller unit.")
- ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
+ ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
description="Open the isolator switch.")
- ifcopenshell.api.run("sequence.add_task", model, parent_task=cleaning, identification="3",
+ ifcopenshell.api.sequence.add_task(model, parent_task=cleaning, identification="3",
description="Setup the water pressure by tapping to a water supply and connecting to a ...")
"""
settings = {
@@ -146,12 +148,8 @@ def add_task(
"predefined_type": predefined_type,
}
- task = ifcopenshell.api.run(
- "root.create_entity",
- file,
- ifc_class="IfcTask",
- name=settings["name"],
- predefined_type=settings["predefined_type"],
+ task = ifcopenshell.api.root.create_entity(
+ file, ifc_class="IfcTask", name=settings["name"], predefined_type=settings["predefined_type"]
)
if settings["description"]:
task.Description = settings["description"]
@@ -163,14 +161,13 @@ def add_task(
"IfcRelAssignsToControl",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [task],
"RelatingControl": settings["work_schedule"],
}
)
elif settings["parent_task"]:
- rel = ifcopenshell.api.run(
- "nest.assign_object",
+ rel = ifcopenshell.api.nest.assign_object(
file,
related_objects=[task],
relating_object=settings["parent_task"],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task_time.py
index 1e755ed6cf..89037d4eb0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task_time.py
@@ -40,25 +40,25 @@ def add_task_time(
.. code:: python
# Let's imagine we are creating a construction schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Create a portion of a work breakdown structure.
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
- superstructure = ifcopenshell.api.run("sequence.add_task", model,
+ superstructure = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Superstructure", identification="C3")
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
parent_task=superstructure, name="Ground Floor FRP", identification="C3.1")
# Add time data. Note that time data is blank by default.
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=task)
+ time = ifcopenshell.api.sequence.add_task_time(model, task=task)
# Let's say our task starts on the first of January when everybody
# is still drunk from the new years celebration, and lasts for 2
# days. Note we don't need to specify the end date, as that is
# derived from the start plus the duration. In this simple example,
# no calendar has been specified, so we are working 24/7. Yikes!
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
"""
settings = {"task": task, "is_recurring": is_recurring}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py
index 26db76c70c..28814da438 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py
@@ -61,24 +61,24 @@ def add_time_period(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
# The morning work session, lunch, then the afternoon work session.
- ifcopenshell.api.run("sequence.add_time_period", model,
+ ifcopenshell.api.sequence.add_time_period(model,
recurrence_pattern=pattern, start_time="09:00", end_time="12:00")
- ifcopenshell.api.run("sequence.add_time_period", model,
+ ifcopenshell.api.sequence.add_time_period(model,
recurrence_pattern=pattern, start_time="13:00", end_time="17:00")
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py
index 97d06983eb..e4af1d88b2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_calendar.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.project
def add_work_calendar(
@@ -50,46 +51,44 @@ def add_work_calendar(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Add a root task to represent the construction tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday), 9am to 5pm
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
- ifcopenshell.api.run("sequence.add_time_period", model,
+ ifcopenshell.api.sequence.add_time_period(model,
recurrence_pattern=pattern, start_time="09:00", end_time="17:00")
# We associate the calendar with the construction root task. All
# subtasks underneath the construction work task will also inherit
# this calendar by default (though you can override them).
- ifcopenshell.api.run("control.assign_control", model, relating_control=calendar, related_object=task)
+ ifcopenshell.api.control.assign_control(model, relating_control=calendar, related_object=task)
"""
settings = {"name": name, "predefined_type": predefined_type}
- work_calendar = ifcopenshell.api.run(
- "root.create_entity",
+ work_calendar = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcWorkCalendar",
predefined_type=settings["predefined_type"],
name=settings["name"],
)
context = file.by_type("IfcContext")[0]
- ifcopenshell.api.run(
- "project.assign_declaration",
+ ifcopenshell.api.project.assign_declaration(
file,
definitions=[work_calendar],
relating_context=context,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py
index 87d01a7dfb..0bd53cb14f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_plan.py
@@ -16,7 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.project
import ifcopenshell.api.owner.settings
import ifcopenshell.util.date
from datetime import datetime, time
@@ -55,10 +56,10 @@ def add_work_plan(
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# This is one of our schedules in our work plan.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model,
name="Construction Schedule A", work_plan=work_plan)
"""
settings = {
@@ -67,8 +68,7 @@ def add_work_plan(
"start_time": start_time or datetime.now(),
}
- work_plan = ifcopenshell.api.run(
- "root.create_entity",
+ work_plan = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcWorkPlan",
predefined_type=settings["predefined_type"],
@@ -81,8 +81,7 @@ def add_work_plan(
work_plan.StartTime = ifcopenshell.util.date.datetime2ifc(settings["start_time"], "IfcDateTime")
context = file.by_type("IfcContext")[0]
- ifcopenshell.api.run(
- "project.assign_declaration",
+ ifcopenshell.api.project.assign_declaration(
file,
definitions=[work_plan],
relating_context=context,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py
index a3bc13886c..4bdc77b955 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py
@@ -16,7 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.project
+import ifcopenshell.api.aggregate
import ifcopenshell.api.owner.settings
import ifcopenshell.util.date
from datetime import time
@@ -60,19 +62,19 @@ def add_work_schedule(
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# Let's imagine this is one of our schedules in our work plan.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model,
name="Construction Schedule A", work_plan=work_plan)
# Add a root task to represent the design milestones, and major
# project phases.
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Milestones", identification="A")
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Design", identification="B")
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
"""
settings = {
@@ -83,8 +85,7 @@ def add_work_schedule(
"work_plan": work_plan,
}
- work_schedule = ifcopenshell.api.run(
- "root.create_entity",
+ work_schedule = ifcopenshell.api.root.create_entity(
file,
ifc_class="IfcWorkSchedule",
predefined_type=settings["predefined_type"],
@@ -104,8 +105,7 @@ def add_work_schedule(
if settings["object_type"]:
work_schedule.ObjectType = settings["object_type"]
if settings["work_plan"]:
- ifcopenshell.api.run(
- "aggregate.assign_object",
+ ifcopenshell.api.aggregate.assign_object(
file,
**{
"products": [work_schedule],
@@ -116,8 +116,7 @@ def add_work_schedule(
# TODO: this is an ambiguity by buildingSMART
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
context = file.by_type("IfcContext")[0]
- ifcopenshell.api.run(
- "project.assign_declaration",
+ ifcopenshell.api.project.assign_declaration(
file,
definitions=[work_schedule],
relating_context=context,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py
index 97ab1f80fd..af55e01a2e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py
@@ -48,30 +48,30 @@ def add_work_time(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
# Let's set some holidays
- holidays = ifcopenshell.api.run("sequence.add_work_time", model,
+ holidays = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="ExceptionTimes")
# We create a yearly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="YEARLY_BY_DAY_OF_MONTH")
# The holiday is every 1st of January
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"DayComponent": [1], "MonthComponent": [1]})
"""
settings = {"work_calendar": work_calendar, "time_type": time_type}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py
index c3986834d6..65ea1db9bd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_lag_time.py
@@ -52,37 +52,37 @@ def assign_lag_time(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're doing a typically formwork, reinforcement,
# pour sequence. Let's start with the formwork. It'll take us 2
# days.
- formwork = ifcopenshell.api.run("sequence.add_task", model,
+ formwork = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Formwork", identification="C.1")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now let's do the reinforcement. It'll take us another 2 days.
- reinforcement = ifcopenshell.api.run("sequence.add_task", model,
+ reinforcement = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Reinforcement", identification="C.2")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now let's say the formwork must finish before the reinforcement
# can start. This is a typical finish to start relationship (FS).
- sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
+ sequence = ifcopenshell.api.sequence.assign_sequence(model,
relating_process=formwork, related_process=reinforcement)
# Now typically there would be no lag time between formwork and
# reinforcement, but let's pretend that we had to allow 1 day gap
# for whatever reason.
- ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1D")
+ ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1D")
"""
settings = {
"rel_sequence": rel_sequence,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py
index 9203d4b4fa..fac605ac40 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_process.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -78,18 +78,18 @@ def assign_process(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Demolish existing", identification="A", predefined_type="DEMOLITION")
# Let's say we have a wall somewhere.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's demolish that wall!
- ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=wall)
+ ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=wall)
"""
settings = {
"relating_process": relating_process,
@@ -109,13 +109,13 @@ def assign_process(
related_objects = list(operates_on.RelatedObjects)
related_objects.append(settings["related_object"])
operates_on.RelatedObjects = related_objects
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": operates_on})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": operates_on})
else:
operates_on = file.create_entity(
"IfcRelAssignsToProcess",
**{
"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"]],
"RelatingProcess": settings["relating_process"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_product.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_product.py
index a033030530..65971cdae4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_product.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -54,18 +54,18 @@ def assign_product(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Build wall", identification="A", predefined_type="CONSTRUCTION")
# Let's say we have a wall somewhere.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's construct that wall!
- ifcopenshell.api.run("sequence.assign_product", model, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(model, relating_product=wall, related_object=task)
"""
settings = {
"relating_product": relating_product,
@@ -85,13 +85,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"],
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py
index 12fe037cc4..0c64fb09e2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py
@@ -76,36 +76,36 @@ def assign_recurrence_pattern(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
# Let's imagine we are creating a maintenance schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Equipment Maintenance")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Equipment Maintenance")
# Now let's imagine we have a task to maintain the chillers
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Chiller maintenance")
# Because it is a maintenance task, we must schedule a recurring time
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=task, is_recurring=True)
+ time = ifcopenshell.api.sequence.add_task_time(model, task=task, is_recurring=True)
# We create a monthly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="MONTHLY_BY_DAY_OF_MONTH")
# Specifically, the maintenance task must occur every 6 months
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"DayComponent": [1], "Interval": 6})
"""
settings = {"parent": parent, "recurrence_type": recurrence_type}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py
index 338a03ceed..664d5780ec 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_sequence.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.sequence
import ifcopenshell.guid
@@ -64,41 +65,41 @@ def assign_sequence(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're doing a typically formwork, reinforcement,
# pour sequence. Let's start with the formwork. It'll take us 2
# days.
- formwork = ifcopenshell.api.run("sequence.add_task", model,
+ formwork = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Formwork", identification="C.1")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now let's do the reinforcement. It'll take us another 2 days.
- reinforcement = ifcopenshell.api.run("sequence.add_task", model,
+ reinforcement = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Reinforcement", identification="C.2")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now the pour it It'll only take 1 day.
- pour = ifcopenshell.api.run("sequence.add_task", model,
+ pour = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Reinforcement", identification="C.3")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=pour)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=pour)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P1D"})
# Now let's say the formwork must finish before the reinforcement
# can start, and the reinforcement must finish before the pour can
# start. This is a typical finish to start relationship (FS).
- ifcopenshell.api.run("sequence.assign_sequence", model,
+ ifcopenshell.api.sequence.assign_sequence(model,
relating_process=formwork, related_process=reinforcement)
- ifcopenshell.api.run("sequence.assign_sequence", model,
+ ifcopenshell.api.sequence.assign_sequence(model,
relating_process=reinforcement, related_process=pour)
# Notice how we set all the scheduled start dates arbitrarily at
@@ -106,7 +107,7 @@ def assign_sequence(
# automatically cascade the dates, starting from any task. This will
# update the reinforcement date to be 2000-01-03 and the pour date
# to be 2000-01-05.
- ifcopenshell.api.run("sequence.cascade_schedule", model, task=formwork)
+ ifcopenshell.api.sequence.cascade_schedule(model, task=formwork)
"""
settings = {
"relating_process": relating_process,
@@ -121,11 +122,11 @@ def assign_sequence(
"IfcRelSequence",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatingProcess": settings["relating_process"],
"RelatedProcess": settings["related_process"],
"SequenceType": settings["sequence_type"],
}
)
- ifcopenshell.api.run("sequence.cascade_schedule", file, task=settings["relating_process"])
+ ifcopenshell.api.sequence.cascade_schedule(file, task=settings["relating_process"])
return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_work_plan.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_work_plan.py
index 8ce1784472..0a32b9d580 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_work_plan.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_work_plan.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.project
+import ifcopenshell.api.aggregate
def assign_work_plan(
@@ -41,26 +42,24 @@ def assign_work_plan(
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# Alternatively, if you create a schedule without a work plan ...
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# ... you can assign the work plan afterwards.
- ifcopenshell.api.run("sequence.assign_work_plan", work_schedule=schedule, work_plan=work_plan)
+ ifcopenshell.api.sequence.assign_work_plan(work_schedule=schedule, work_plan=work_plan)
"""
settings = {"work_schedule": work_schedule, "work_plan": work_plan}
# TODO: this is an ambiguity by buildingSMART
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
file,
definitions=[settings["work_schedule"]],
relating_context=file.by_type("IfcContext")[0],
)
- rel_aggregates = ifcopenshell.api.run(
- "aggregate.assign_object",
+ rel_aggregates = ifcopenshell.api.aggregate.assign_object(
file,
**{
"products": [settings["work_schedule"]],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/calculate_task_duration.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/calculate_task_duration.py
index 95dd1a652b..7c3f821e7e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/calculate_task_duration.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/calculate_task_duration.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import math
-import ifcopenshell.api
+import ifcopenshell.api.sequence
import ifcopenshell.util.date
import ifcopenshell.util.element
@@ -44,41 +44,41 @@ def calculate_task_duration(file: ifcopenshell.file, task: ifcopenshell.entity_i
.. code:: python
# Add our own crew
- crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")
+ crew = ifcopenshell.api.resource.add_resource(model, ifc_class="IfcCrewResource")
# Add some labour to our crew.
- labour = ifcopenshell.api.run("resource.add_resource", model,
+ labour = ifcopenshell.api.resource.add_resource(model,
parent_resource=crew, ifc_class="IfcLaborResource")
# Labour resource is quantified in terms of time.
- quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
+ quantity = ifcopenshell.api.resource.add_resource_quantity(model,
resource=labour, ifc_class="IfcQuantityTime")
# Store the unit time used in hours
- ifcopenshell.api.run("resource.edit_resource_quantity", model,
+ ifcopenshell.api.resource.edit_resource_quantity(model,
physical_quantity=quantity, attributes={"TimeValue": 8.0})
# Let's imagine we've used the resource for 10 days with a
# utilisation of 200%.
- time = ifcopenshell.api.run("resource.add_resource_time", model, resource=labour)
- ifcopenshell.api.run("resource.edit_resource_time", model,
+ time = ifcopenshell.api.resource.add_resource_time(model, resource=labour)
+ ifcopenshell.api.resource.edit_resource_time(model,
resource_time=time, attributes={"ScheduleWork": "PT80H", "ScheduleUsage": 2})
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Foundations", identification="A")
# Assign our resource to the task.
- ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=labour)
+ ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=labour)
# Now we can calculate the task duration based on the resource. This
# will set task.TaskTime.ScheduleDuration to be P5D.
- ifcopenshell.api.run("sequence.calculate_task_duration", model, task=task)
+ ifcopenshell.api.sequence.calculate_task_duration(model, task=task)
"""
usecase = Usecase()
usecase.file = file
@@ -142,5 +142,5 @@ class Usecase:
def set_task_duration(self, duration):
if not self.settings["task"].TaskTime:
- ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.settings["task"])
+ ifcopenshell.api.sequence.add_task_time(self.file, task=self.settings["task"])
self.settings["task"].TaskTime.ScheduleDuration = f"P{duration}D"
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/cascade_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/cascade_schedule.py
index 22207d4622..8a989ecb55 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/cascade_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/cascade_schedule.py
@@ -52,19 +52,19 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
# Define a convenience function to add a task chained to a predecessor
def add_task(model, name, predecessor, work_schedule):
# Add a construction task
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=work_schedule, name=name, predefined_type="CONSTRUCTION")
# Give it a time
- task_time = ifcopenshell.api.run("sequence.add_task_time", model, task=task)
+ task_time = ifcopenshell.api.sequence.add_task_time(model, task=task)
# Arbitrarily set the task's scheduled time duration to be 1 week
- ifcopenshell.api.run("sequence.edit_task_time", model, task_time=task_time,
+ ifcopenshell.api.sequence.edit_task_time(model, task_time=task_time,
attributes={"ScheduleStart": datetime.date(2000, 1, 1), "ScheduleDuration": "P1W"})
# If a predecessor exists, create a finish to start relationship
if predecessor:
- ifcopenshell.api.run("sequence.assign_sequence", model,
+ ifcopenshell.api.sequence.assign_sequence(model,
relating_process=predecessor, related_process=task)
return task
@@ -73,7 +73,7 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
model = ifcopenshell.open("/path/to/existing/model.ifc")
# Create a new construction schedule
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction")
# Let's imagine a starting task for site establishment.
task = add_task(model, "Site establishment", None, schedule)
@@ -90,16 +90,16 @@ def cascade_schedule(file: ifcopenshell.file, task: ifcopenshell.entity_instance
# Assign all the products in that storey to the task as construction outputs.
for product in get_decomposition(storey):
- ifcopenshell.api.run("sequence.assign_product", model, relating_product=product, related_object=task)
+ ifcopenshell.api.sequence.assign_product(model, relating_product=product, related_object=task)
# Ask the computer to calculate all the dates for us from the start task.
# For example, if the first task started on the 1st of January and took a
# week, the next task will start on the 8th of January. This saves us
# manually doing date calculations.
- ifcopenshell.api.run("sequence.cascade_schedule", model, task=start_task)
+ ifcopenshell.api.sequence.cascade_schedule(model, task=start_task)
# Calculate the critical path and floats.
- ifcopenshell.api.run("sequence.recalculate_schedule", model, work_schedule=schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(model, work_schedule=schedule)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/create_baseline.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/create_baseline.py
index 8a7439de89..d0670b76e8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/create_baseline.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/create_baseline.py
@@ -17,7 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.control
+import ifcopenshell.api.sequence
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.sequence
@@ -49,13 +51,14 @@ def create_baseline(
:rtype: ifcopenshell.entity_instance
Example:
+
.. code:: python
# We have a Work Schedule
planned_work_schedule = WorkSchedule(name="Design new feature",predefinedType="PLANNED", deadline="2023-03-01")
# And now we have a baseline for our Work Schedule
- baseline_work_schedule = ifcopenshell.api.run("sequence.create_baseline",file, work_schedule= planned_work_schedule, name="Baseline 1")
+ baseline_work_schedule = ifcopenshell.api.sequence.create_baseline(file, work_schedule=planned_work_schedule, name="Baseline 1")
"""
usecase = Usecase()
usecase.file = file
@@ -72,25 +75,15 @@ class Usecase:
# create work schedule
if not work_schedule.PredefinedType == "PLANNED":
return
- baseline_work_schedule = ifcopenshell.api.run(
- "sequence.add_work_schedule",
- self.file,
- name=work_schedule.Name,
- predefined_type="BASELINE",
+ baseline_work_schedule = ifcopenshell.api.sequence.add_work_schedule(
+ self.file, name=work_schedule.Name, predefined_type="BASELINE"
)
baseline_work_schedule.Name = self.settings["name"]
self.create_baseline_reference(work_schedule, baseline_work_schedule)
for summary_task in ifcopenshell.util.sequence.get_root_tasks(work_schedule):
- current, duplicate = ifcopenshell.api.run(
- "sequence.duplicate_task",
- self.file,
- task=summary_task,
- )
- ifcopenshell.api.run(
- "control.assign_control",
- self.file,
- relating_control=baseline_work_schedule,
- related_object=duplicate[0],
+ current, duplicate = ifcopenshell.api.sequence.duplicate_task(self.file, task=summary_task)
+ ifcopenshell.api.control.assign_control(
+ self.file, relating_control=baseline_work_schedule, related_object=duplicate[0]
)
for i, task in enumerate(current):
self.create_baseline_reference(task, duplicate[i])
@@ -103,15 +96,13 @@ class Usecase:
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(related_object)
referenced_by.RelatedObjects = related_objects
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": referenced_by})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
else:
referenced_by = self.file.create_entity(
"IfcRelDefinesByObject",
- **{
- "GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
- "RelatedObjects": [related_object],
- "RelatingObject": relating_object,
- }
+ GlobalId=ifcopenshell.guid.new(),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
+ RelatedObjects=[related_object],
+ RelatingObject=relating_object,
)
return referenced_by
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/duplicate_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/duplicate_task.py
index 0861c1bd19..db47ccd5ec 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/duplicate_task.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/duplicate_task.py
@@ -18,7 +18,9 @@
import ifcopenshell
import ifcopenshell.guid
-import ifcopenshell.api
+import ifcopenshell.api.nest
+import ifcopenshell.api.owner
+import ifcopenshell.api.sequence
import ifcopenshell.util.element
import ifcopenshell.util.sequence
@@ -83,9 +85,8 @@ class Usecase:
inverse = ifcopenshell.util.element.copy(self.file, inverse)
inverse.RelatingObject = to_element
inverse.RelatedObjects = new_tasks
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=new_tasks)
- ifcopenshell.api.run(
- "nest.assign_object",
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=new_tasks)
+ ifcopenshell.api.nest.assign_object(
self.file,
related_objects=new_tasks,
relating_object=to_element,
@@ -133,15 +134,13 @@ class Usecase:
else: # thus the relating process is not part of the duplicated tasks
relating_process = inverse.RelatingProcess
if relating_process and related_process:
- rel = ifcopenshell.api.run(
- "sequence.assign_sequence",
+ rel = ifcopenshell.api.sequence.assign_sequence(
self.file,
relating_process=relating_process,
related_process=related_process,
)
if inverse.TimeLag:
- ifcopenshell.api.run(
- "sequence.assign_lag_time",
+ ifcopenshell.api.sequence.assign_lag_time(
self.file,
rel_sequence=rel,
lag_value=(
@@ -160,13 +159,13 @@ class Usecase:
related_objects = list(referenced_by.RelatedObjects)
related_objects.append(related_object)
referenced_by.RelatedObjects = related_objects
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": referenced_by})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": referenced_by})
else:
referenced_by = self.file.create_entity(
"IfcRelDefinesByObject",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(self.file),
"RelatedObjects": [related_object],
"RelatingObject": relating_object,
}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_lag_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_lag_time.py
index 89d042ed40..d3c8a4418a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_lag_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_lag_time.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.sequence
import ifcopenshell.util.date
from typing import Any
@@ -40,40 +40,40 @@ def edit_lag_time(file: ifcopenshell.file, lag_time: ifcopenshell.entity_instanc
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're doing a typically formwork, reinforcement,
# pour sequence. Let's start with the formwork. It'll take us 2
# days.
- formwork = ifcopenshell.api.run("sequence.add_task", model,
+ formwork = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Formwork", identification="C.1")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now let's do the reinforcement. It'll take us another 2 days.
- reinforcement = ifcopenshell.api.run("sequence.add_task", model,
+ reinforcement = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Reinforcement", identification="C.2")
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=reinforcement)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=reinforcement)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
# Now let's say the formwork must finish before the reinforcement
# can start. This is a typical finish to start relationship (FS).
- sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
+ sequence = ifcopenshell.api.sequence.assign_sequence(model,
relating_process=formwork, related_process=reinforcement)
# Now typically there would be no lag time between formwork and
# reinforcement, but let's pretend that we had to allow 1 day gap
# for whatever reason.
- lag = ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1D")
+ lag = ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1D")
# Or, let's make it 2 days instead.
- ifcopenshell.api.run("sequence.edit_lag_time", model, lag_time=lag, attributes={"LagValue": "P2D"})
+ ifcopenshell.api.sequence.edit_lag_time(model, lag_time=lag, attributes={"LagValue": "P2D"})
"""
settings = {"lag_time": lag_time, "attributes": attributes}
@@ -85,4 +85,4 @@ def edit_lag_time(file: ifcopenshell.file, lag_time: ifcopenshell.entity_instanc
value = file.createIfcDuration(ifcopenshell.util.date.datetime2ifc(value, "IfcDuration"))
setattr(settings["lag_time"], name, value)
for rel in [r for r in file.get_inverse(settings["lag_time"]) if r.is_a("IfcRelSequence")]:
- ifcopenshell.api.run("sequence.cascade_schedule", file, task=rel.RelatedProcess)
+ ifcopenshell.api.sequence.cascade_schedule(file, task=rel.RelatedProcess)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py
index 489aa66d6f..6b165f716a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py
@@ -41,18 +41,18 @@ def edit_recurrence_pattern(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
"""
settings = {
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_sequence.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_sequence.py
index b83baa9cb2..dee8a32e64 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_sequence.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_sequence.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.sequence
from typing import Any
@@ -42,24 +42,24 @@ def edit_sequence(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're building 2 zones, one after another.
- zone1 = ifcopenshell.api.run("sequence.add_task", model,
+ zone1 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 1", identification="C.1")
- zone2 = ifcopenshell.api.run("sequence.add_task", model,
+ zone2 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 2", identification="C.2")
# Zone 1 finishes, then zone 2 starts.
- sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
+ sequence = ifcopenshell.api.sequence.assign_sequence(model,
relating_process=zone1, related_process=zone2)
# What if they both started at the same time?
- ifcopenshell.api.run("sequence.edit_sequence", model,
+ ifcopenshell.api.sequence.edit_sequence(model,
rel_sequence=sequence, attributes={"SequenceType": "START_START"})
"""
settings = {"rel_sequence": rel_sequence, "attributes": attributes}
@@ -67,8 +67,4 @@ def edit_sequence(
for name, value in settings["attributes"].items():
setattr(settings["rel_sequence"], name, value)
if "SequenceType" in settings["attributes"].keys():
- ifcopenshell.api.run(
- "sequence.cascade_schedule",
- file,
- task=settings["rel_sequence"].RelatedProcess,
- )
+ ifcopenshell.api.sequence.cascade_schedule(file, task=settings["rel_sequence"].RelatedProcess)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task.py
index 325c6bdce1..dcd218059f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task.py
@@ -38,15 +38,15 @@ def edit_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance, attri
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Add a root task to represent the design milestones, and major
# project phases.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Milestones", identification="A")
# Change the identification
- ifcopenshell.api.run("sequence.edit_task", model, task=task, attributes={"Identification": "M"})
+ ifcopenshell.api.sequence.edit_task(model, task=task, attributes={"Identification": "M"})
"""
settings = {"task": task, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py
index d0ecfa29d8..6d9d3404d1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_task_time.py
@@ -17,6 +17,8 @@
# along with IfcOpenShell. If not, see .
import datetime
+import ifcopenshell.api.sequence
+import ifcopenshell.api.resource
import ifcopenshell.util.constraint
import ifcopenshell.util.date
import ifcopenshell.util.sequence
@@ -46,15 +48,15 @@ def edit_task_time(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Create a task to do formwork
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Formwork", identification="A")
# Let's say it takes 2 days and starts on the 1st of January, 2000
- time = ifcopenshell.api.run("sequence.add_task_time", model, task=formwork)
- ifcopenshell.api.run("sequence.edit_task_time", model,
+ time = ifcopenshell.api.sequence.add_task_time(model, task=formwork)
+ ifcopenshell.api.sequence.edit_task_time(model,
task_time=time, attributes={"ScheduleStart": "2000-01-01", "ScheduleDuration": "P2D"})
"""
usecase = Usecase()
@@ -117,7 +119,7 @@ class Usecase:
or "ScheduleFinish" in self.settings["attributes"].keys()
or "ScheduleDuration" in self.settings["attributes"].keys()
):
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=self.task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=self.task)
if self.settings["task_time"].ScheduleDuration:
self.handle_resource_calculation()
@@ -152,7 +154,7 @@ class Usecase:
resources = ifcopenshell.util.sequence.get_task_resources(self.task, is_deep=False)
for resource in resources:
if ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleWork"):
- ifcopenshell.api.run("resource.calculate_resource_usage", self.file, resource=resource)
+ ifcopenshell.api.resource.calculate_resource_usage(self.file, resource=resource)
# TODO: If the duration changes, this implies the productivity rate must change to accomModate the new Schedule Work to be calculated.
# elif ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleUsage"):
- # ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ # ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_calendar.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_calendar.py
index 6bcfcb3fd3..f82f53e534 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_calendar.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_calendar.py
@@ -39,10 +39,10 @@ def edit_work_calendar(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
# Let's give it a description
- ifcopenshell.api.run("sequence.edit_work_calendar", model,
+ ifcopenshell.api.sequence.edit_work_calendar(model,
work_calendar=calendar, attributes={"Description": "Monday to Friday 8 hour days"})
"""
settings = {"work_calendar": work_calendar, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_plan.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_plan.py
index a5e96c16bb..920e2c671e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_plan.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_plan.py
@@ -40,10 +40,10 @@ def edit_work_plan(
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# Let's give it a description
- ifcopenshell.api.run("sequence.edit_work_plan", model,
+ ifcopenshell.api.sequence.edit_work_plan(model,
work_plan=work_plan, attributes={"Description": "Construction of phase 1"})
"""
settings = {"work_plan": work_plan, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_schedule.py
index 5179073e70..5ed392ddff 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_schedule.py
@@ -40,14 +40,14 @@ def edit_work_schedule(
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# Let's imagine this is one of our schedules in our work plan.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model,
name="Construction Schedule A", work_plan=work_plan)
# Let's give it a description
- ifcopenshell.api.run("sequence.edit_work_schedule", model,
+ ifcopenshell.api.sequence.edit_work_schedule(model,
work_schedule=work_schedule, attributes={"Description": "3 crane design option"})
"""
settings = {"work_schedule": work_schedule, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_time.py
index 5f16eba16a..07c1f818d5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_work_time.py
@@ -42,16 +42,16 @@ def edit_work_time(
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# If we don't specify any recurring time periods in our work time,
# we need to specify a start and end date of the work time. It
# starts at 0:00 on the start date and 24:00 at the end date.
- ifcopenshell.api.run("sequence.edit_work_time", model,
+ ifcopenshell.api.sequence.edit_work_time(model,
work_time=work_time, attributes={"StartDate": "2000-01-01", "FinishDate": "2000-01-02"})
"""
settings = {"work_time": work_time, "attributes": attributes}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py
index ab80999339..a7fb9d01e6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py
@@ -18,7 +18,7 @@
import datetime
import networkx as nx
-import ifcopenshell.api
+import ifcopenshell.api.sequence
import ifcopenshell.util.date
import ifcopenshell.util.sequence
@@ -184,8 +184,7 @@ class Usecase:
task = self.file.by_id(ifc_definition_id)
if not task.TaskTime:
continue
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task.TaskTime,
attributes={
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_task.py
index f753f04f97..9af73898ea 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_task.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_task.py
@@ -17,8 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.pset
import ifcopenshell.api.nest
+import ifcopenshell.api.project
import ifcopenshell.api.sequence
import ifcopenshell.util.element
@@ -40,26 +41,25 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Add a root task to represent the design milestones, and major
# project phases.
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Milestones", identification="A")
- design = ifcopenshell.api.run("sequence.add_task", model,
+ design = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Design", identification="B")
- ifcopenshell.api.run("sequence.add_task", model,
+ ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Ah, let's delete the design section, who needs it anyway we'll
# just fix it on site.
- ifcopenshell.api.run("sequence.remove_task", model, task=design)
+ ifcopenshell.api.sequence.remove_task(model, task=design)
"""
settings = {"task": task}
# TODO: do a deep purge
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
file,
definitions=[settings["task"]],
relating_context=file.by_type("IfcContext")[0],
@@ -75,7 +75,7 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
# Use batching for optimization.
ifcopenshell.api.nest.unassign_object(file, subtasks)
for task_ in subtasks:
- ifcopenshell.api.run("sequence.remove_task", file, task=task_)
+ ifcopenshell.api.sequence.remove_task(file, task=task_)
if settings["task"].Nests:
ifcopenshell.api.nest.unassign_object(file, [settings["task"]])
@@ -96,8 +96,7 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
related_objects.remove(settings["task"])
inverse.RelatedObjects = related_objects
elif inverse.is_a("IfcRelDefinesByProperties"):
- ifcopenshell.api.run(
- "pset.remove_pset",
+ ifcopenshell.api.pset.remove_pset(
file,
product=settings["task"],
pset=inverse.RelatingPropertyDefinition,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py
index 0102c552dc..247323c04a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py
@@ -32,28 +32,28 @@ def remove_time_period(file: ifcopenshell.file, time_period: ifcopenshell.entity
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# State that we work from weekdays 1 to 5 (i.e. Monday to Friday)
- ifcopenshell.api.run("sequence.edit_recurrence_pattern", model,
+ ifcopenshell.api.sequence.edit_recurrence_pattern(model,
recurrence_pattern=pattern, attributes={"WeekdayComponent": [1, 2, 3, 4, 5]})
# The morning work session, lunch, then the afternoon work session.
- morning = ifcopenshell.api.run("sequence.add_time_period", model,
+ morning = ifcopenshell.api.sequence.add_time_period(model,
recurrence_pattern=pattern, start_time="09:00", end_time="12:00")
- afternoon = ifcopenshell.api.run("sequence.add_time_period", model,
+ afternoon = ifcopenshell.api.sequence.add_time_period(model,
recurrence_pattern=pattern, start_time="13:00", end_time="17:00")
# Let's take the afternoon off!
- ifcopenshell.api.run("sequence.remove_time_period", model, time_period=afternoon)
+ ifcopenshell.api.sequence.remove_time_period(model, time_period=afternoon)
"""
settings = {"time_period": time_period}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_calendar.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_calendar.py
index a51390c368..27213630e5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_calendar.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_calendar.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.control
+import ifcopenshell.api.project
import ifcopenshell.api.sequence
import ifcopenshell.util.element
@@ -38,16 +39,15 @@ def remove_work_calendar(file: ifcopenshell.file, work_calendar: ifcopenshell.en
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model, name="5 Day Week")
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model, name="5 Day Week")
# And remove it immediately
- ifcopenshell.api.run("sequence.remove_work_calendar", model, work_calendar=calendar)
+ ifcopenshell.api.sequence.remove_work_calendar(model, work_calendar=calendar)
"""
settings = {"work_calendar": work_calendar}
# TODO: do a deep purge
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
file,
definitions=[settings["work_calendar"]],
relating_context=file.by_type("IfcContext")[0],
@@ -55,8 +55,7 @@ def remove_work_calendar(file: ifcopenshell.file, work_calendar: ifcopenshell.en
if settings["work_calendar"].Controls:
for rel in settings["work_calendar"].Controls:
for related_object in rel.RelatedObjects:
- ifcopenshell.api.run(
- "control.unassign_control",
+ ifcopenshell.api.control.unassign_control(
file,
relating_control=settings["work_calendar"],
related_object=related_object,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_plan.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_plan.py
index bf027f1581..4f655fbd0c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_plan.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_plan.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.project
import ifcopenshell.api.aggregate
import ifcopenshell.util.element
@@ -38,15 +38,14 @@ def remove_work_plan(file: ifcopenshell.file, work_plan: ifcopenshell.entity_ins
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# And remove it immediately
- ifcopenshell.api.run("sequence.remove_work_plan", model, work_plan=work_plan)
+ ifcopenshell.api.sequence.remove_work_plan(model, work_plan=work_plan)
"""
settings = {"work_plan": work_plan}
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
file,
definitions=[settings["work_plan"]],
relating_context=file.by_type("IfcContext")[0],
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py
index 1a6d8b8e2b..d14258e6ec 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_schedule.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.project
+import ifcopenshell.api.sequence
import ifcopenshell.api.aggregate
import ifcopenshell.util.element
@@ -37,33 +38,26 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
.. code:: python
# This will hold all our construction schedules
- work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
+ work_plan = ifcopenshell.api.sequence.add_work_plan(model, name="Construction")
# Let's imagine this is one of our schedules in our work plan.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model,
name="Construction Schedule A", work_plan=work_plan)
# And remove it immediately
- ifcopenshell.api.run("sequence.remove_work_schedule", model, work_schedule=schedule)
+ ifcopenshell.api.sequence.remove_work_schedule(model, work_schedule=schedule)
"""
settings = {"work_schedule": work_schedule}
# TODO: do a deep purge
- ifcopenshell.api.run(
- "project.unassign_declaration",
- file,
- definitions=[settings["work_schedule"]],
- relating_context=file.by_type("IfcContext")[0],
+ ifcopenshell.api.project.unassign_declaration(
+ file, definitions=[settings["work_schedule"]], relating_context=file.by_type("IfcContext")[0]
)
if settings["work_schedule"].Declares:
for rel in settings["work_schedule"].Declares:
for work_schedule in rel.RelatedObjects:
- ifcopenshell.api.run(
- "sequence.remove_work_schedule",
- file,
- work_schedule=work_schedule,
- )
+ ifcopenshell.api.sequence.remove_work_schedule(file, work_schedule=work_schedule)
# Unassign from work plans.
if settings["work_schedule"].Decomposes:
@@ -82,7 +76,7 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
inverse.RelatedObjects = related_objects
elif inverse.is_a("IfcRelAssignsToControl"):
[
- ifcopenshell.api.run("sequence.remove_task", file, task=related_object)
+ ifcopenshell.api.sequence.remove_task(file, task=related_object)
for related_object in inverse.RelatedObjects
if related_object.is_a("IfcTask")
]
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py
index c3cadfe42a..4fdd1d1f9a 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py
@@ -32,14 +32,14 @@ def remove_work_time(file: ifcopenshell.file, work_time: ifcopenshell.entity_ins
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# And remove it immediately
- ifcopenshell.api.run("sequence.remove_work_time", model, work_time=work_time)
+ ifcopenshell.api.sequence.remove_work_time(model, work_time=work_time)
"""
# Currently in API recurrence patterns are created during assignment
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_lag_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_lag_time.py
index 716bb64b8b..08ffcd9f40 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_lag_time.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_lag_time.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.sequence
def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity_instance) -> None:
@@ -35,27 +35,27 @@ def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're building 2 zones, one after another.
- zone1 = ifcopenshell.api.run("sequence.add_task", model,
+ zone1 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 1", identification="C.1")
- zone2 = ifcopenshell.api.run("sequence.add_task", model,
+ zone2 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 2", identification="C.2")
# Zone 1 finishes, then zone 2 starts.
- sequence = ifcopenshell.api.run("sequence.assign_sequence", model,
+ sequence = ifcopenshell.api.sequence.assign_sequence(model,
relating_process=zone1, related_process=zone2)
# What if you had to wait 1 week before you could start zone 2?
- ifcopenshell.api.run("sequence.assign_lag_time", model, rel_sequence=sequence, lag_value="P1W")
+ ifcopenshell.api.sequence.assign_lag_time(model, rel_sequence=sequence, lag_value="P1W")
# What if you didn't?
- ifcopenshell.api.run("sequence.unassign_lag_time", model, rel_sequence=sequence)
+ ifcopenshell.api.sequence.unassign_lag_time(model, rel_sequence=sequence)
"""
settings = {
"rel_sequence": rel_sequence,
@@ -65,8 +65,4 @@ def unassign_lag_time(file: ifcopenshell.file, rel_sequence: ifcopenshell.entity
file.remove(settings["rel_sequence"].TimeLag)
else:
settings["rel_sequence"].TimeLag = None
- ifcopenshell.api.run(
- "sequence.cascade_schedule",
- file,
- task=settings["rel_sequence"].RelatedProcess,
- )
+ ifcopenshell.api.sequence.cascade_schedule(file, task=settings["rel_sequence"].RelatedProcess)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_process.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_process.py
index 08d9b8ab4f..20e801a76c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_process.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_process.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -43,21 +43,21 @@ def unassign_process(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Demolish existing", identification="A", predefined_type="DEMOLITION")
# Let's say we have a wall somewhere.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's demolish that wall!
- ifcopenshell.api.run("sequence.assign_process", model, relating_process=task, related_object=wall)
+ ifcopenshell.api.sequence.assign_process(model, relating_process=task, related_object=wall)
# Change our mind.
- ifcopenshell.api.run("sequence.unassign_process", model, relating_process=task, related_object=wall)
+ ifcopenshell.api.sequence.unassign_process(model, relating_process=task, related_object=wall)
"""
settings = {
"relating_process": relating_process,
@@ -76,5 +76,5 @@ def unassign_process(
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)
return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_product.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_product.py
index 4dc4ee4845..30f2675aeb 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_product.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -43,21 +43,21 @@ def unassign_product(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Build wall", identification="A", predefined_type="CONSTRUCTION")
# Let's say we have a wall somewhere.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's construct that wall!
- ifcopenshell.api.run("sequence.assign_product", relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(relating_product=wall, related_object=task)
# Change our mind.
- ifcopenshell.api.run("sequence.unassign_product", relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.unassign_product(relating_product=wall, related_object=task)
"""
settings = {
"relating_product": relating_product,
@@ -76,5 +76,5 @@ 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)
return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_recurrence_pattern.py
index 6a39c644ce..2ba9cdb229 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_recurrence_pattern.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_recurrence_pattern.py
@@ -37,18 +37,18 @@ def unassign_recurrence_pattern(file: ifcopenshell.file, recurrence_pattern: ifc
.. code:: python
# Let's create a new calendar.
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", model)
+ calendar = ifcopenshell.api.sequence.add_work_calendar(model)
# Let's start defining the times that we work during the week.
- work_time = ifcopenshell.api.run("sequence.add_work_time", model,
+ work_time = ifcopenshell.api.sequence.add_work_time(model,
work_calendar=calendar, time_type="WorkingTimes")
# We create a weekly recurrence
- pattern = ifcopenshell.api.run("sequence.assign_recurrence_pattern", model,
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(model,
parent=work_time, recurrence_type="WEEKLY")
# Change our mind, let's just maintain it whenever we feel like it.
- ifcopenshell.api.run("sequence.unassign_recurrence_pattern", recurrence_pattern=pattern)
+ ifcopenshell.api.sequence.unassign_recurrence_pattern(recurrence_pattern=pattern)
"""
settings = {"recurrence_pattern": recurrence_pattern}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_sequence.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_sequence.py
index 277dfc67ee..eea4e3eff5 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_sequence.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/unassign_sequence.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.sequence
import ifcopenshell.util.element
@@ -41,23 +41,23 @@ def unassign_sequence(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's imagine a root construction task
- construction = ifcopenshell.api.run("sequence.add_task", model,
+ construction = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Construction", identification="C")
# Let's imagine we're building 2 zones, one after another.
- zone1 = ifcopenshell.api.run("sequence.add_task", model,
+ zone1 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 1", identification="C.1")
- zone2 = ifcopenshell.api.run("sequence.add_task", model,
+ zone2 = ifcopenshell.api.sequence.add_task(model,
parent_task=construction, name="Zone 2", identification="C.2")
# Zone 1 finishes, then zone 2 starts.
- ifcopenshell.api.run("sequence.assign_sequence", model, relating_process=zone1, related_process=zone2)
+ ifcopenshell.api.sequence.assign_sequence(model, relating_process=zone1, related_process=zone2)
# Let's make them unrelated
- ifcopenshell.api.run("sequence.unassign_sequence", model,
+ ifcopenshell.api.sequence.unassign_sequence(model,
relating_process=zone1, related_process=zone2)
"""
settings = {
@@ -71,4 +71,4 @@ def unassign_sequence(
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
- ifcopenshell.api.run("sequence.cascade_schedule", file, task=settings["related_process"])
+ ifcopenshell.api.sequence.cascade_schedule(file, task=settings["related_process"])
diff --git a/src/ifcopenshell-python/ifcopenshell/api/spatial/assign_container.py b/src/ifcopenshell-python/ifcopenshell/api/spatial/assign_container.py
index 02343e4303..81dca88437 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/spatial/assign_container.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/spatial/assign_container.py
@@ -18,7 +18,9 @@
import ifcopenshell
import ifcopenshell.guid
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
import ifcopenshell.util.element
import ifcopenshell.util.placement
from typing import Union
@@ -79,27 +81,27 @@ def assign_container(
.. code:: python
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
- site = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- building = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- storey = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
- space = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSpace")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
+ site = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ building = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ storey = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
+ space = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSpace")
# The project contains a site (note that project aggregation is a special case in IFC)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[site], relating_object=project)
+ ifcopenshell.api.aggregate.assign_object(model, products=[site], relating_object=project)
# The site has a building, the building has a storey, and the storey has a space
- ifcopenshell.api.run("aggregate.assign_object", model, products=[building], relating_object=site)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[storey], relating_object=building)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[space], relating_object=storey)
+ ifcopenshell.api.aggregate.assign_object(model, products=[building], relating_object=site)
+ ifcopenshell.api.aggregate.assign_object(model, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(model, products=[space], relating_object=storey)
# Create a wall and furniture
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
- furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
+ furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
# The wall is in the storey, and the furniture is in the space
- ifcopenshell.api.run("spatial.assign_container", model, products=[wall], relating_structure=storey)
- ifcopenshell.api.run("spatial.assign_container", model, products=[furniture], relating_structure=space)
+ ifcopenshell.api.spatial.assign_container(model, products=[wall], relating_structure=storey)
+ ifcopenshell.api.spatial.assign_container(model, products=[furniture], relating_structure=space)
"""
settings = {
"products": products,
@@ -138,14 +140,14 @@ def assign_container(
return structure_rel
# can be either only aggregated or only contained at the same time
- ifcopenshell.api.run("aggregate.unassign_object", file, products=products_without_containers)
+ ifcopenshell.api.aggregate.unassign_object(file, products=products_without_containers)
# unassign elements from previous containers
for rel in previous_containers_rels:
related_elements = set(rel.RelatedElements) - products
if related_elements:
rel.RelatedElements = list(related_elements)
- 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)
@@ -155,13 +157,13 @@ def assign_container(
# assign elements to a new container
if structure_rel:
structure_rel.RelatedElements = list(set(structure_rel.RelatedElements) | products)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": structure_rel})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": structure_rel})
else:
structure_rel = file.create_entity(
"IfcRelContainedInSpatialStructure",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedElements": list(products),
"RelatingStructure": settings["relating_structure"],
}
@@ -171,8 +173,7 @@ def assign_container(
for product in products_to_change:
placement = getattr(product, "ObjectPlacement", None)
if placement and placement.is_a("IfcLocalPlacement"):
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
file,
product=product,
matrix=ifcopenshell.util.placement.get_local_placement(product.ObjectPlacement),
diff --git a/src/ifcopenshell-python/ifcopenshell/api/spatial/dereference_structure.py b/src/ifcopenshell-python/ifcopenshell/api/spatial/dereference_structure.py
index 50eb72305b..bb31cd7c7d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/spatial/dereference_structure.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/spatial/dereference_structure.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -40,33 +40,33 @@ def dereference_structure(
.. code:: python
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
- site = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- building = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- storey1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
- storey2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
- storey3 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
+ site = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ building = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ storey1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
+ storey2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
+ storey3 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
# The project contains a site (note that project aggregation is a special case in IFC)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[site], relating_object=project)
+ ifcopenshell.api.aggregate.assign_object(model, products=[site], relating_object=project)
# The site has a building, the building has a storey, and the storey has a space
- ifcopenshell.api.run("aggregate.assign_object", model, products=[building], relating_object=site)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[storey], relating_object=building)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[space], relating_object=storey)
+ ifcopenshell.api.aggregate.assign_object(model, products=[building], relating_object=site)
+ ifcopenshell.api.aggregate.assign_object(model, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(model, products=[space], relating_object=storey)
# Create a column, this column spans 3 storeys
- column = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ column = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# The column is contained in the lowermost storey
- ifcopenshell.api.run("spatial.assign_container", model, products=[column], relating_structure=storey1)
+ ifcopenshell.api.spatial.assign_container(model, products=[column], relating_structure=storey1)
# And referenced in the others
- ifcopenshell.api.run("spatial.reference_structure", model, products=[column], relating_structure=storey2)
- ifcopenshell.api.run("spatial.reference_structure", model, products=[column], relating_structure=storey3)
+ ifcopenshell.api.spatial.reference_structure(model, products=[column], relating_structure=storey2)
+ ifcopenshell.api.spatial.reference_structure(model, products=[column], relating_structure=storey3)
# Actually, it only goes up to storey 2.
- ifcopenshell.api.run("spatial.dereference_structure", model, products=[column], relating_structure=storey3)
+ ifcopenshell.api.spatial.dereference_structure(model, products=[column], relating_structure=storey3)
"""
settings = {"products": products, "relating_structure": relating_structure}
@@ -78,7 +78,7 @@ def dereference_structure(
related_elements = related_elements - products
if related_elements:
rel.RelatedElements = list(related_elements)
- 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/spatial/reference_structure.py b/src/ifcopenshell-python/ifcopenshell/api/spatial/reference_structure.py
index 19fe199cb1..2897219e68 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/spatial/reference_structure.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/spatial/reference_structure.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union
@@ -59,30 +59,30 @@ def reference_structure(
.. code:: python
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
- site = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- building = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- storey1 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
- storey2 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
- storey3 = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
+ site = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ building = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ storey1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
+ storey2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
+ storey3 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
# The project contains a site (note that project aggregation is a special case in IFC)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[site], relating_object=project)
+ ifcopenshell.api.aggregate.assign_object(model, products=[site], relating_object=project)
# The site has a building, the building has a storey, and the storey has a space
- ifcopenshell.api.run("aggregate.assign_object", model, products=[building], relating_object=site)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[storey], relating_object=building)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[space], relating_object=storey)
+ ifcopenshell.api.aggregate.assign_object(model, products=[building], relating_object=site)
+ ifcopenshell.api.aggregate.assign_object(model, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(model, products=[space], relating_object=storey)
# Create a column, this column spans 3 storeys
- column = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ column = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# The column is contained in the lowermost storey
- ifcopenshell.api.run("spatial.assign_container", model, products=[column], relating_structure=storey1)
+ ifcopenshell.api.spatial.assign_container(model, products=[column], relating_structure=storey1)
# And referenced in the others
- ifcopenshell.api.run(
- "spatial.reference_structure", model, products=[column], relating_structure=[storey2, storey3]
+ ifcopenshell.api.spatial.reference_structure(
+ model, products=[column], relating_structure=[storey2, storey3]
)
"""
settings = {
@@ -106,16 +106,14 @@ def reference_structure(
if rel is None:
rel = file.create_entity(
"IfcRelReferencedInSpatialStructure",
- **{
- "GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
- "RelatedElements": list(products_to_assign),
- "RelatingStructure": structure,
- }
+ GlobalId=ifcopenshell.guid.new(),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
+ RelatedElements=list(products_to_assign),
+ RelatingStructure=structure,
)
else:
related_elements = set(rel.RelatedElements) | products_to_assign
rel.RelatedElements = list(related_elements)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(file, element=rel)
return rel
diff --git a/src/ifcopenshell-python/ifcopenshell/api/spatial/unassign_container.py b/src/ifcopenshell-python/ifcopenshell/api/spatial/unassign_container.py
index b6afbc13c9..9567fa4841 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/spatial/unassign_container.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/spatial/unassign_container.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -33,26 +33,26 @@ def unassign_container(file: ifcopenshell.file, products: list[ifcopenshell.enti
.. code:: python
- project = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
- site = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSite")
- building = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuilding")
- storey = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBuildingStorey")
+ project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
+ site = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
+ building = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
+ storey = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
# The project contains a site (note that project aggregation is a special case in IFC)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[site], relating_object=project)
+ ifcopenshell.api.aggregate.assign_object(model, products=[site], relating_object=project)
# The site has a building, the building has a storey, and the storey has a space
- ifcopenshell.api.run("aggregate.assign_object", model, products=[building], relating_object=site)
- ifcopenshell.api.run("aggregate.assign_object", model, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(model, products=[building], relating_object=site)
+ ifcopenshell.api.aggregate.assign_object(model, products=[storey], relating_object=building)
# Create a wall
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# The wall is in the storey
- ifcopenshell.api.run("spatial.assign_container", model, products=[wall], relating_structure=storey)
+ ifcopenshell.api.spatial.assign_container(model, products=[wall], relating_structure=storey)
# Not anymore!
- ifcopenshell.api.run("spatial.unassign_container", model, products=[wall])
+ ifcopenshell.api.spatial.unassign_container(model, products=[wall])
"""
settings = {
"products": products,
@@ -65,7 +65,7 @@ def unassign_container(file: ifcopenshell.file, products: list[ifcopenshell.enti
related_elements = set(rel.RelatedElements) - products
if related_elements:
rel.RelatedElements = list(related_elements)
- 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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_activity.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_activity.py
index 7680dfd90d..53d07abcc6 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_activity.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_activity.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py
index ca6f3e2b52..16759969eb 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_analysis_model.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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"
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_boundary_condition.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_boundary_condition.py
index fa88d76b57..36c232ecdd 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_boundary_condition.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_boundary_condition.py
@@ -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}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load.py
index d996a84c86..f9d4fb4316 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load.py
@@ -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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_case.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_case.py
index 32f9906c90..d8823a11f1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_case.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_case.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-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",
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_group.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_group.py
index 36aa6bdd80..a86ed1393d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_group.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_load_group.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-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",
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py
index df6d98ef3e..077e0a55fc 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/add_structural_member_connection.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/assign_structural_analysis_model.py b/src/ifcopenshell-python/ifcopenshell/api/structural/assign_structural_analysis_model.py
index 39d4d652bf..dd96f543b2 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/assign_structural_analysis_model.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/assign_structural_analysis_model.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py
index 91eb517640..c16a441753 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/remove_structural_connection_condition.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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,
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/structural/unassign_structural_analysis_model.py b/src/ifcopenshell-python/ifcopenshell/api/structural/unassign_structural_analysis_model.py
index 28e6531bfa..6fd53aa80d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/structural/unassign_structural_analysis_model.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/structural/unassign_structural_analysis_model.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/add_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/add_style.py
index 2660cc6335..f43d87ddd9 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/add_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/add_style.py
@@ -56,7 +56,7 @@ def add_style(
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
"""
kwargs = {"Name": name}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/add_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/add_surface_style.py
index 4c80a4ae42..408f8e7906 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/add_surface_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/add_surface_style.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.style
from typing import Any, Optional, Literal
@@ -99,17 +99,17 @@ def add_surface_style(
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Create a simple shading colour and transparency.
- ifcopenshell.api.run("style.add_surface_style", model,
+ ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleShading", attributes={
"SurfaceColour": { "Name": None, "Red": 1.0, "Green": 0.8, "Blue": 0.8 },
"Transparency": 0., # 0 is opaque, 1 is transparent
})
# Alternatively, create a rendering style.
- ifcopenshell.api.run("style.add_surface_style", model,
+ ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleRendering", attributes={
# A surface colour and transparency is still supplied for
# viewport display only. This will supersede the shading
@@ -130,7 +130,7 @@ def add_surface_style(
settings = {"style": style, "ifc_class": ifc_class, "attributes": attributes or {}}
style_item = file.create_entity(settings["ifc_class"])
- ifcopenshell.api.run("style.edit_surface_style", file, style=style_item, attributes=settings["attributes"])
+ ifcopenshell.api.style.edit_surface_style(file, style=style_item, attributes=settings["attributes"])
styles = list(settings["style"].Styles or [])
select_class = settings["ifc_class"]
@@ -138,7 +138,7 @@ def add_surface_style(
select_class = "IfcSurfaceStyleShading"
duplicate_items = [s for s in styles if s.is_a(select_class)]
for duplicate_item in duplicate_items:
- ifcopenshell.api.run("style.remove_surface_style", file, style=duplicate_item)
+ ifcopenshell.api.style.remove_surface_style(file, style=duplicate_item)
styles = list(settings["style"].Styles or [])
styles.append(style_item)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py
index b1ddd3e298..3ecc91177f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.style
import ifcopenshell.util.element
@@ -59,41 +59,41 @@ def assign_material_style(
.. code:: python
# A model context is needed to store 3D geometry
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
# Specifically, we want to store body geometry
- body = ifcopenshell.api.run("context.add_context", model,
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Let's create a new wall. The wall does not have any geometry yet.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's use the "3D Body" representation we created earlier to add a
# new wall-like body geometry, 5 meters long, 3 meters high, and
# 200mm thick
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
# Assign our new body geometry back to our wall
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Let's prepare a concrete material. Note that our concrete material
# does not have any colours (styles) at this point.
- concrete = ifcopenshell.api.run("material.add_material", model, name="CON01", category="concrete")
+ concrete = ifcopenshell.api.material.add_material(model, name="CON01", category="concrete")
# Assign our concrete material to our wall
- ifcopenshell.api.run("material.assign_material", model,
+ ifcopenshell.api.material.assign_material(model,
products=[wall], type="IfcMaterial", material=concrete)
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Create a simple grey shading colour and transparency.
- ifcopenshell.api.run("style.add_surface_style", model,
+ ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleShading", attributes={
"SurfaceColour": { "Name": None, "Red": 0.5, "Green": 0.5, "Blue": 0.5 },
"Transparency": 0., # 0 is opaque, 1 is transparent
@@ -101,7 +101,7 @@ def assign_material_style(
# Now any element (like our wall) with a concrete material will have
# a grey colour applied.
- ifcopenshell.api.run("style.assign_material_style", model, material=concrete, style=style, context=body)
+ ifcopenshell.api.style.assign_material_style(model, material=concrete, style=style, context=body)
"""
usecase = Usecase()
usecase.file = file
@@ -143,8 +143,8 @@ class Usecase:
continue
for rep in shape_aspect.ShapeRepresentations:
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, shape_representation=rep, styles=[self.style]
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, shape_representation=rep, styles=[self.style]
)
def modify_existing_definition_representation(self):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py b/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py
index 2aa95e6d94..afa30cfb15 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py
@@ -64,40 +64,40 @@ def assign_representation_styles(
.. code:: python
# A model context is needed to store 3D geometry
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
# Specifically, we want to store body geometry
- body = ifcopenshell.api.run("context.add_context", model,
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Let's create a new wall. The wall does not have any geometry yet.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's use the "3D Body" representation we created earlier to add a
# new wall-like body geometry, 5 meters long, 3 meters high, and
# 200mm thick
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
# Assign our new body geometry back to our wall
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Create a simple grey shading colour and transparency.
- ifcopenshell.api.run("style.add_surface_style", model,
+ ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleShading", attributes={
"SurfaceColour": { "Name": None, "Red": 0.5, "Green": 0.5, "Blue": 0.5 },
"Transparency": 0., # 0 is opaque, 1 is transparent
})
# Now specifically our wall only will be coloured grey.
- ifcopenshell.api.run("style.assign_representation_styles", model,
+ ifcopenshell.api.style.assign_representation_styles(model,
shape_representation=representation, styles=[style])
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/edit_presentation_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/edit_presentation_style.py
index e8934d4de5..d1a42e5d9e 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/edit_presentation_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/edit_presentation_style.py
@@ -39,10 +39,10 @@ def edit_presentation_style(
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Change the name of the style to "Foo"
- ifcopenshell.api.run("style.edit_presentation_style", model, style=style, attributes={"Name": "Foo"})
+ ifcopenshell.api.style.edit_presentation_style(model, style=style, attributes={"Name": "Foo"})
"""
settings = {"style": style, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py
index 9dbb9245f6..c5be1d757f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/edit_surface_style.py
@@ -47,14 +47,14 @@ def edit_surface_style(
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Create a blank rendering style.
- rendering = ifcopenshell.api.run("style.add_surface_style", model,
+ rendering = ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleRendering")
# Edit the attributes of the rendering style.
- ifcopenshell.api.run("style.edit_surface_style", model,
+ ifcopenshell.api.style.edit_surface_style(model,
style=rendering, attributes={
# A surface colour and transparency is still supplied for
# viewport display only. This will supersede the shading
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/remove_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/remove_style.py
index 1868847ba4..65fe7af288 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/remove_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/remove_style.py
@@ -15,7 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+
+import ifcopenshell.api.style
import ifcopenshell.util.element
@@ -34,10 +35,10 @@ def remove_style(file: ifcopenshell.file, style: ifcopenshell.entity_instance) -
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Not anymore!
- ifcopenshell.api.run("style.remove_style", model, style=style)
+ ifcopenshell.api.style.remove_style(model, style=style)
"""
usecase = Usecase()
usecase.file = file
@@ -49,7 +50,7 @@ class Usecase:
def execute(self):
self.purge_styled_items(self.settings["style"])
for style in self.settings["style"].Styles or []:
- ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
+ ifcopenshell.api.style.remove_surface_style(self.file, style=style)
self.file.remove(self.settings["style"])
def purge_styled_items(self, style):
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/remove_styled_representation.py b/src/ifcopenshell-python/ifcopenshell/api/style/remove_styled_representation.py
index 8b4323f0de..bc6267f0f7 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/remove_styled_representation.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/remove_styled_representation.py
@@ -34,7 +34,7 @@ def remove_styled_representation(file: ifcopenshell.file, representation: ifcope
.. code:: python
# Remove a styled representation
- ifcopenshell.api.run("style.remove_styled_representation", model, representation=representation)
+ ifcopenshell.api.style.remove_styled_representation(model, representation=representation)
"""
settings = {"representation": representation}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py
index 98674c5f84..bad29c878f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py
@@ -33,17 +33,17 @@ def remove_surface_style(file: ifcopenshell.file, style: ifcopenshell.entity_ins
.. code:: python
# Create a new surface style
- style = ifcopenshell.api.run("style.add_style", model)
+ style = ifcopenshell.api.style.add_style(model)
# Create a simple shading colour and transparency.
- shading = ifcopenshell.api.run("style.add_surface_style", model,
+ shading = ifcopenshell.api.style.add_surface_style(model,
style=style, ifc_class="IfcSurfaceStyleShading", attributes={
"SurfaceColour": { "Name": None, "Red": 1.0, "Green": 0.8, "Blue": 0.8 },
"Transparency": 0., # 0 is opaque, 1 is transparent
})
# Remove the shading item
- ifcopenshell.api.run("style.remove_surface_style", model, style=shading)
+ ifcopenshell.api.style.remove_surface_style(model, style=shading)
"""
to_delete = set()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py
index 17d0adfb3a..47c7c337f8 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py
@@ -18,7 +18,7 @@
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.style
import ifcopenshell.util.element
@@ -48,7 +48,7 @@ def unassign_material_style(
.. code:: python
- ifcopenshell.api.run("style.unassign_material_style", model, material=concrete, style=style, context=body)
+ ifcopenshell.api.style.unassign_material_style(model, material=concrete, style=style, context=body)
"""
settings = {
"material": material,
@@ -100,9 +100,6 @@ def unassign_material_style(
continue
for rep in shape_aspect.ShapeRepresentations:
- ifcopenshell.api.run(
- "style.unassign_representation_styles",
- file,
- shape_representation=rep,
- styles=[settings["style"]],
+ ifcopenshell.api.style.unassign_representation_styles(
+ file, shape_representation=rep, styles=[settings["style"]]
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_representation_styles.py b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_representation_styles.py
index 4f5685b150..f56fad763c 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_representation_styles.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_representation_styles.py
@@ -49,7 +49,7 @@ def unassign_representation_styles(
.. code:: python
- ifcopenshell.api.run("style.unassign_representation_styles", model,
+ ifcopenshell.api.style.unassign_representation_styles(model,
shape_representation=representation, styles=[style])
"""
usecase = Usecase()
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/add_port.py b/src/ifcopenshell-python/ifcopenshell/api/system/add_port.py
index e6311a72e9..faa7c7a584 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/add_port.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/add_port.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
from typing import Optional
@@ -44,18 +45,18 @@ def add_port(file: ifcopenshell.file, element: Optional[ifcopenshell.entity_inst
.. code:: python
# Create a duct
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
# Create 2 ports, one for either end.
- port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
- port2 = ifcopenshell.api.run("system.add_port", model, element=duct)
+ port1 = ifcopenshell.api.system.add_port(model, element=duct)
+ port2 = ifcopenshell.api.system.add_port(model, element=duct)
"""
settings = {
"element": element,
}
- port = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcDistributionPort")
+ port = ifcopenshell.api.root.create_entity(file, ifc_class="IfcDistributionPort")
if settings["element"]:
- ifcopenshell.api.run("system.assign_port", file, element=settings["element"], port=port)
+ ifcopenshell.api.system.assign_port(file, element=settings["element"], port=port)
return port
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py
index 195bca640f..a9272ee989 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/add_system.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
@@ -43,7 +43,7 @@ def add_system(file: ifcopenshell.file, ifc_class: str = "IfcDistributionSystem"
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
"""
settings = {"ifc_class": ifc_class}
@@ -56,7 +56,7 @@ def add_system(file: ifcopenshell.file, ifc_class: str = "IfcDistributionSystem"
ifc_class,
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"Name": "Unnamed",
}
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/assign_flow_control.py b/src/ifcopenshell-python/ifcopenshell/api/system/assign_flow_control.py
index 6b6dcd9be2..b41db08c79 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/assign_flow_control.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/assign_flow_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Union
@@ -47,9 +47,8 @@ def assign_flow_control(
flow_element = model.createIfcFlowSegment()
flow_control = model.createIfcController()
- relation = ifcopenshell.api.run(
- "system.assign_flow_control", model,
- related_flow_control=flow_control, relating_flow_element=flow_element
+ relation = ifcopenshell.api.system.assign_flow_control(
+ model, related_flow_control=flow_control, relating_flow_element=flow_element
)
"""
settings = {
@@ -73,14 +72,14 @@ def assign_flow_control(
related_flow_controls = set(assignment.RelatedControlElements)
related_flow_controls.add(settings["related_flow_control"])
assignment.RelatedControlElements = list(related_flow_controls)
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": assignment})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": assignment})
return assignment
assignment = file.create_entity(
"IfcRelFlowControlElements",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedControlElements": [settings["related_flow_control"]],
"RelatingFlowElement": settings["relating_flow_element"],
},
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/assign_port.py b/src/ifcopenshell-python/ifcopenshell/api/system/assign_port.py
index 7f801fc919..bfa3b5e37f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/assign_port.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/assign_port.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.geometry
import ifcopenshell.guid
import ifcopenshell.util.placement
@@ -44,18 +45,18 @@ def assign_port(
.. code:: python
# Create a duct
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
# Create 2 ports, one for either end.
- port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
- port2 = ifcopenshell.api.run("system.add_port", model, element=duct)
+ port1 = ifcopenshell.api.system.add_port(model, element=duct)
+ port2 = ifcopenshell.api.system.add_port(model, element=duct)
# Unassign one port for some weird reason.
- ifcopenshell.api.run("system.unassign_port", model, element=duct, port=port1)
+ ifcopenshell.api.system.unassign_port(model, element=duct, port=port1)
# Reassign it back
- ifcopenshell.api.run("system.assign_port", model, element=duct, port=port1)
+ ifcopenshell.api.system.assign_port(model, element=duct, port=port1)
"""
usecase = Usecase()
usecase.file = file
@@ -82,12 +83,12 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set()
related_objects.add(self.settings["port"])
rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
else:
rel = self.file.create_entity(
"IfcRelNests",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatedObjects=[self.settings["port"]],
RelatingObject=self.settings["element"],
)
@@ -103,7 +104,7 @@ class Usecase:
rel = self.file.create_entity(
"IfcRelConnectsPortToElement",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingPort=self.settings["port"],
RelatedElement=self.settings["element"],
)
@@ -113,8 +114,7 @@ class Usecase:
def update_port_placement(self):
placement = getattr(self.settings["port"], "ObjectPlacement", None)
if placement and placement.is_a("IfcLocalPlacement"):
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=self.settings["port"],
matrix=ifcopenshell.util.placement.get_local_placement(self.settings["port"].ObjectPlacement),
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/assign_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/assign_system.py
index e0b19c5165..4e6f5b89ee 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/assign_system.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/assign_system.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.group
import ifcopenshell.util.system
@@ -43,14 +43,14 @@ def assign_system(
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Create a duct
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
# This duct is part of the system
- ifcopenshell.api.run("system.assign_system", model, products=[duct], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[duct], system=system)
"""
settings = {
"products": products,
@@ -63,5 +63,4 @@ def assign_system(
if not all(ifcopenshell.util.system.is_assignable(failed_product := product, system) for product in products):
raise TypeError(f"You cannot assign an {failed_product.is_a()} to an {system.is_a()}")
- rel = ifcopenshell.api.run("group.assign_group", file, products=products, group=system)
- return rel
+ return ifcopenshell.api.group.assign_group(file, products=products, group=system)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/connect_port.py b/src/ifcopenshell-python/ifcopenshell/api/system/connect_port.py
index aea8575dce..9a1bc76f43 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/connect_port.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/connect_port.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Optional
@@ -75,28 +75,28 @@ def connect_port(
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Create a duct and a 90 degree bend fitting
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
- fitting = ifcopenshell.api.run("root.create_entity", model,
+ fitting = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctFitting", predefined_type="BEND")
# The duct and fitting is part of the system
- ifcopenshell.api.run("system.assign_system", model, products=[duct], system=system)
- ifcopenshell.api.run("system.assign_system", model, products=[fitting], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[duct], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[fitting], system=system)
# Create 2 ports, one for either end of both the duct and fitting.
- duct_port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
- duct_port2 = ifcopenshell.api.run("system.add_port", model, element=duct)
- fitting_port1 = ifcopenshell.api.run("system.add_port", model, element=fitting)
- fitting_port2 = ifcopenshell.api.run("system.add_port", model, element=fitting)
+ duct_port1 = ifcopenshell.api.system.add_port(model, element=duct)
+ duct_port2 = ifcopenshell.api.system.add_port(model, element=duct)
+ fitting_port1 = ifcopenshell.api.system.add_port(model, element=fitting)
+ fitting_port2 = ifcopenshell.api.system.add_port(model, element=fitting)
# Connect the duct and fitting together. At this point, we have not
# yet determined the direction of the flow, so we leave direction as
# NOTDEFINED.
- ifcopenshell.api.run("system.connect_port", model, port1=duct_port2, port2=fitting_port1)
+ ifcopenshell.api.system.connect_port(model, port1=duct_port2, port2=fitting_port1)
"""
usecase = Usecase()
usecase.file = file
@@ -180,7 +180,7 @@ class Usecase:
self.file.create_entity(
"IfcRelConnectsPorts",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingPort=self.settings["port1"],
RelatedPort=self.settings["port2"],
)
@@ -192,7 +192,7 @@ class Usecase:
self.file.create_entity(
"IfcRelConnectsPorts",
GlobalId=ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingPort=self.settings["port2"],
RelatedPort=self.settings["port1"],
)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/disconnect_port.py b/src/ifcopenshell-python/ifcopenshell/api/system/disconnect_port.py
index bb2cd9364f..cd6cd38fb1 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/disconnect_port.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/disconnect_port.py
@@ -37,32 +37,32 @@ def disconnect_port(file: ifcopenshell.file, port: ifcopenshell.entity_instance)
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Create a duct and a 90 degree bend fitting
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
- fitting = ifcopenshell.api.run("root.create_entity", model,
+ fitting = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctFitting", predefined_type="BEND")
# The duct and fitting is part of the system
- ifcopenshell.api.run("system.assign_system", model, products=[duct], system=system)
- ifcopenshell.api.run("system.assign_system", model, products=[fitting], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[duct], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[fitting], system=system)
# Create 2 ports, one for either end of both the duct and fitting.
- duct_port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
- duct_port2 = ifcopenshell.api.run("system.add_port", model, element=duct)
- fitting_port1 = ifcopenshell.api.run("system.add_port", model, element=fitting)
- fitting_port2 = ifcopenshell.api.run("system.add_port", model, element=fitting)
+ duct_port1 = ifcopenshell.api.system.add_port(model, element=duct)
+ duct_port2 = ifcopenshell.api.system.add_port(model, element=duct)
+ fitting_port1 = ifcopenshell.api.system.add_port(model, element=fitting)
+ fitting_port2 = ifcopenshell.api.system.add_port(model, element=fitting)
# Connect the duct and fitting together. At this point, we have not
# yet determined the direction of the flow, so we leave direction as
# NOTDEFINED.
- ifcopenshell.api.run("system.connect_port", model, port1=duct_port2, port2=fitting_port1)
+ ifcopenshell.api.system.connect_port(model, port1=duct_port2, port2=fitting_port1)
# Disconnect the port. note we could've equally disconnected
# fitting_port1 instead of duct_port2
- ifcopenshell.api.run("system.disconnect_port", model, port=duct_port2)
+ ifcopenshell.api.system.disconnect_port(model, port=duct_port2)
"""
settings = {
"port": port,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/edit_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/edit_system.py
index d8c45f495e..00311b7ac0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/edit_system.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/edit_system.py
@@ -37,10 +37,10 @@ def edit_system(file: ifcopenshell.file, system: ifcopenshell.entity_instance, a
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Change the name of the system to "HW" for Hot Water
- ifcopenshell.api.run("system.edit_system", model, system=system, attributes={"Name": "HW"})
+ ifcopenshell.api.system.edit_system(model, system=system, attributes={"Name": "HW"})
"""
settings = {"system": system, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/remove_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/remove_system.py
index 0d1fcf3853..cef253cded 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/remove_system.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/remove_system.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.pset
import ifcopenshell.util.element
@@ -36,10 +36,10 @@ def remove_system(file: ifcopenshell.file, system: ifcopenshell.entity_instance)
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Delete it.
- ifcopenshell.api.run("system.remove_system", model, system=system)
+ ifcopenshell.api.system.remove_system(model, system=system)
"""
settings = {"system": system}
@@ -49,8 +49,7 @@ def remove_system(file: ifcopenshell.file, system: ifcopenshell.entity_instance)
except:
continue
if inverse.is_a("IfcRelDefinesByProperties"):
- ifcopenshell.api.run(
- "pset.remove_pset",
+ ifcopenshell.api.pset.remove_pset(
file,
product=settings["system"],
pset=inverse.RelatingPropertyDefinition,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_flow_control.py b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_flow_control.py
index 40a4efdadd..4aeefe5a47 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_flow_control.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_flow_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -43,13 +43,12 @@ def unassign_flow_control(
# assign control to the flow element
flow_element = file.createIfcFlowSegment()
flow_control = file.createIfcController()
- relation = ifcopenshell.api.run(
- "system.assign_flow_control", file,
- relating_control=flow_control, related_object=flow_element
+ relation = ifcopenshell.api.system.assign_flow_control(
+ file, relating_control=flow_control, related_object=flow_element
)
# und unassign it
- ifcopenshell.api.run("system.unassign_flow_control", file,
+ ifcopenshell.api.system.unassign_flow_control(file,
relating_control=flow_control, related_object=flow_element
)
"""
@@ -73,4 +72,4 @@ def unassign_flow_control(
related_flow_controls = list(assignment.RelatedControlElements)
related_flow_controls.remove(settings["related_flow_control"])
assignment.RelatedControlElements = related_flow_controls
- ifcopenshell.api.run("owner.update_owner_history", file, **{"element": assignment})
+ ifcopenshell.api.owner.update_owner_history(file, **{"element": assignment})
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_port.py b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_port.py
index c7e079fbf0..1bf459920f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_port.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_port.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -42,15 +42,15 @@ def unassign_port(
.. code:: python
# Create a duct
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
# Create 2 ports, one for either end.
- port1 = ifcopenshell.api.run("system.add_port", model, element=duct)
- port2 = ifcopenshell.api.run("system.add_port", model, element=duct)
+ port1 = ifcopenshell.api.system.add_port(model, element=duct)
+ port2 = ifcopenshell.api.system.add_port(model, element=duct)
# Unassign one port for some weird reason.
- ifcopenshell.api.run("system.unassign_port", model, element=duct, port=port1)
+ ifcopenshell.api.system.unassign_port(model, element=duct, port=port1)
"""
usecase = Usecase()
usecase.file = file
@@ -77,7 +77,7 @@ class Usecase:
related_objects = set(rel.RelatedObjects) or set()
related_objects.remove(self.settings["port"])
rel.RelatedObjects = list(related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": rel})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": rel})
def execute_ifc2x3(self):
for rel in self.settings["element"].HasPorts or []:
diff --git a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py
index 7bb82aebb7..4956b33b56 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/system/unassign_system.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.group
import ifcopenshell.util.element
@@ -40,21 +40,21 @@ def unassign_system(
.. code:: python
# A completely empty distribution system
- system = ifcopenshell.api.run("system.add_system", model)
+ system = ifcopenshell.api.system.add_system(model)
# Create a duct
- duct = ifcopenshell.api.run("root.create_entity", model,
+ duct = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcDuctSegment", predefined_type="RIGIDSEGMENT")
# This duct is part of the system
- ifcopenshell.api.run("system.assign_system", model, products=[duct], system=system)
+ ifcopenshell.api.system.assign_system(model, products=[duct], system=system)
# Not anymore!
- ifcopenshell.api.run("system.unassign_system", model, products=[duct], system=system)
+ ifcopenshell.api.system.unassign_system(model, products=[duct], system=system)
"""
settings = {
"products": products,
"system": system,
}
- ifcopenshell.api.run("group.unassign_group", file, products=settings["products"], group=settings["system"])
+ ifcopenshell.api.group.unassign_group(file, products=settings["products"], group=settings["system"])
diff --git a/src/ifcopenshell-python/ifcopenshell/api/type/assign_type.py b/src/ifcopenshell-python/ifcopenshell/api/type/assign_type.py
index 670297593a..2a20f57f2f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/type/assign_type.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/type/assign_type.py
@@ -17,7 +17,9 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.type
+import ifcopenshell.api.owner
+import ifcopenshell.api.material
import ifcopenshell.guid
import ifcopenshell.util.element
from typing import Union, Iterable
@@ -109,24 +111,24 @@ def assign_type(
# A furniture type. This would correlate to a particular model in a
# manufacturer's catalogue. Like an Ikea sofa :)
- furniture_type = ifcopenshell.api.run("root.create_entity", model,
+ furniture_type = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcFurnitureType", name="FUN01")
# An individual occurrence of a that sofa.
- furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
+ furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
# Assign the furniture to the furniture type. If the furniture_type
# had a representation, the furniture occurrence will also now have
# the exact same representation. This is highly efficient as you
# don't need to define the representation for every occurrence.
- ifcopenshell.api.run("type.assign_type", model, related_objects=[furniture], relating_type=furniture_type)
+ ifcopenshell.api.type.assign_type(model, related_objects=[furniture], relating_type=furniture_type)
# Let's imagine a parametric material layer set
- wall_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWallType", name="WAL01")
+ wall_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType", name="WAL01")
# First, let's create a material set. This will later be assigned
# to our wall type element.
- material_set = ifcopenshell.api.run("material.add_material_set", model,
+ material_set = ifcopenshell.api.material.add_material_set(model,
name="GYP-ST-GYP", set_type="IfcMaterialLayerSet")
# Let's create a few materials, it's important to also give them
@@ -134,44 +136,44 @@ def assign_type(
# like "show me everything made out of aluminium / concrete / steel
# / glass / etc". The IFC specification states a list of categories
# you can use.
- gypsum = ifcopenshell.api.run("material.add_material", model, name="PB01", category="gypsum")
- steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
+ gypsum = ifcopenshell.api.material.add_material(model, name="PB01", category="gypsum")
+ steel = ifcopenshell.api.material.add_material(model, name="ST01", category="steel")
# Now let's use those materials as three layers in our set, such
# that the steel studs are sandwiched by the gypsum. Let's imagine
# we're setting the layer thickness in millimeters.
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": .013})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=steel)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": .092})
- layer = ifcopenshell.api.run("material.add_layer", model, layer_set=material_set, material=gypsum)
- ifcopenshell.api.run("material.edit_layer", model, layer=layer, attributes={"LayerThickness": .013})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": .013})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=steel)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": .092})
+ layer = ifcopenshell.api.material.add_layer(model, layer_set=material_set, material=gypsum)
+ ifcopenshell.api.material.edit_layer(model, layer=layer, attributes={"LayerThickness": .013})
# Great! Let's assign our material set to our wall type.
- ifcopenshell.api.run("material.assign_material", model, products=[wall_type], material=material_set)
+ ifcopenshell.api.material.assign_material(model, products=[wall_type], material=material_set)
# Now, let's create a wall.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# The wall is a WAL01 wall type.
- ifcopenshell.api.run("type.assign_type", model, related_objects=[wall], relating_type=wall_type)
+ ifcopenshell.api.type.assign_type(model, related_objects=[wall], relating_type=wall_type)
# A bit of preparation, let's create some geometric contexts since
# we want to create some geometry for our wall.
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Notice how our thickness of 0.118 must equal .013 + .092 + .013 from our type
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.118)
# Assign our new body geometry back to our wall
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
"""
usecase = Usecase()
usecase.file = file
@@ -230,7 +232,7 @@ class Usecase:
cur_related_objects = set(is_typed_by.RelatedObjects) - related_objects
if cur_related_objects:
is_typed_by.RelatedObjects = list(cur_related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": is_typed_by})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": is_typed_by})
else:
history = is_typed_by.OwnerHistory
self.file.remove(is_typed_by)
@@ -240,23 +242,20 @@ class Usecase:
# assign objects to a new type
if types:
types.RelatedObjects = list(set(types.RelatedObjects) | related_objects)
- ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": types})
+ ifcopenshell.api.owner.update_owner_history(self.file, **{"element": types})
else:
types = self.file.create_entity(
"IfcRelDefinesByType",
- **{
- "GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
- "RelatedObjects": list(related_objects),
- "RelatingType": relating_type,
- },
+ GlobalId=ifcopenshell.guid.new(),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
+ RelatedObjects=list(related_objects),
+ RelatingType=relating_type,
)
if self.settings["should_map_representations"]:
if getattr(relating_type, "RepresentationMaps", None):
for related_object in objects_to_change:
- ifcopenshell.api.run(
- "type.map_type_representations",
+ ifcopenshell.api.type.map_type_representations(
self.file,
related_object=related_object,
relating_type=relating_type,
@@ -270,8 +269,7 @@ class Usecase:
return
ifc_class = type_material.is_a()
if ifc_class in ("IfcMaterialLayerSet", "IfcMaterialProfileSet"):
- ifcopenshell.api.run(
- "material.assign_material",
+ ifcopenshell.api.material.assign_material(
self.file,
products=related_objects,
type=f"{ifc_class}Usage",
diff --git a/src/ifcopenshell-python/ifcopenshell/api/type/map_type_representations.py b/src/ifcopenshell-python/ifcopenshell/api/type/map_type_representations.py
index 59c1655c6f..995408b063 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/type/map_type_representations.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/type/map_type_representations.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.geometry
import ifcopenshell.util.element
@@ -45,29 +45,29 @@ def map_type_representations(
# A furniture type. This would correlate to a particular model in a
# manufacturer's catalogue. Like an Ikea sofa :)
- furniture_type = ifcopenshell.api.run("root.create_entity", model,
+ furniture_type = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcFurnitureType", name="FUN01")
# An individual occurrence of a that sofa.
- furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
+ furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
# Place our furniture at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=furniture)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=furniture)
# Assign the furniture to the furniture type. Right now, the
# furniture type has no representation, so the furniture may also
# have no representation, or any arbitrary representation that may
# vary from occurrence to occurrence.
- ifcopenshell.api.run("type.assign_type", model, related_objects=[furniture], relating_type=furniture_type)
+ ifcopenshell.api.type.assign_type(model, related_objects=[furniture], relating_type=furniture_type)
# A bit of preparation, let's create some geometric contexts since
# we want to create some geometry for our furniture type.
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Let's create a mesh representation of an arbitrary 2m cube.
- representation = ifcopenshell.api.run("geometry.add_sverchok_representation", model, context=body,
+ representation = ifcopenshell.api.geometry.add_sverchok_representation(model, context=body,
vertices=[[(-1.0, -1.0, 0.0), (-1.0, -1.0, 2.0), (-1.0, 1.0, 0.0), (-1.0, 1.0, 2.0),
(1.0, -1.0, 0.0), (1.0, -1.0, 2.0), (1.0, 1.0, 0.0), (1.0, 1.0, 2.0)]],
faces=[[[0, 1, 3, 2], [2, 3, 7, 6], [6, 7, 5, 4], [4, 5, 1, 0], [2, 6, 4, 0], [7, 3, 1, 5]]])
@@ -75,13 +75,13 @@ def map_type_representations(
# Assign our new body geometry back to our furniture type. In this
# case, since we use the API, all occurrences automatically get the
# representation mapped, so there is nothing more we need to do.
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=furniture_type, representation=representation)
# However, if you were doing some sort of manual IFC patching, like
# assigning furniture_type.RepresentationMaps directly, then you
# might make this call:
- # ifcopenshell.api.run("type.map_type_representations", model,
+ # ifcopenshell.api.type.map_type_representations(model,
# related_object=furniture, relating_type=furniture_type)
"""
settings = {
@@ -95,18 +95,16 @@ def map_type_representations(
if settings["related_object"].Representation:
representations = settings["related_object"].Representation.Representations
for representation in representations:
- ifcopenshell.api.run(
- "geometry.unassign_representation",
+ ifcopenshell.api.geometry.unassign_representation(
file,
product=settings["related_object"],
representation=representation,
)
- ifcopenshell.api.run("geometry.remove_representation", file, **{"representation": representation})
+ ifcopenshell.api.geometry.remove_representation(file, **{"representation": representation})
for representation_map in settings["relating_type"].RepresentationMaps:
representation = representation_map.MappedRepresentation
- mapped_representation = ifcopenshell.api.run("geometry.map_representation", file, representation=representation)
- ifcopenshell.api.run(
- "geometry.assign_representation",
+ mapped_representation = ifcopenshell.api.geometry.map_representation(file, representation=representation)
+ ifcopenshell.api.geometry.assign_representation(
file,
product=settings["related_object"],
representation=mapped_representation,
diff --git a/src/ifcopenshell-python/ifcopenshell/api/type/unassign_type.py b/src/ifcopenshell-python/ifcopenshell/api/type/unassign_type.py
index cbc41a7785..2723dd760f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/type/unassign_type.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/type/unassign_type.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.util.element
@@ -38,17 +38,17 @@ def unassign_type(file: ifcopenshell.file, related_objects: list[ifcopenshell.en
# A furniture type. This would correlate to a particular model in a
# manufacturer's catalogue. Like an Ikea sofa :)
- furniture_type = ifcopenshell.api.run("root.create_entity", model,
+ furniture_type = ifcopenshell.api.root.create_entity(model,
ifc_class="IfcFurnitureType", name="FUN01")
# An individual occurrence of a that sofa.
- furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
+ furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
# Assign the furniture to the furniture type.
- ifcopenshell.api.run("type.assign_type", model, related_objects=[furniture], relating_type=furniture_type)
+ ifcopenshell.api.type.assign_type(model, related_objects=[furniture], relating_type=furniture_type)
# Change our mind. Maybe it's a different type?
- ifcopenshell.api.run("type.unassign_type", model, related_objects=[furniture])
+ ifcopenshell.api.type.unassign_type(model, related_objects=[furniture])
"""
settings = {"related_objects": related_objects}
@@ -67,7 +67,7 @@ def unassign_type(file: ifcopenshell.file, related_objects: list[ifcopenshell.en
related_objects = set(rel.RelatedObjects) - related_objects
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)
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py
index ee37c32f53..135c805f2f 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_context_dependent_unit.py
@@ -55,7 +55,7 @@ def add_context_dependent_unit(
.. code:: python
# Boxes of things
- ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
+ ifcopenshell.api.unit.add_context_dependent_unit(model, name="BOXES")
"""
settings = {"unit_type": unit_type, "name": name, "dimensions": dimensions}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_conversion_based_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_conversion_based_unit.py
index b87011b2e1..daa91145ee 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_conversion_based_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_conversion_based_unit.py
@@ -53,11 +53,11 @@ def add_conversion_based_unit(
.. code:: python
# Some common imperial measurements
- length = ifcopenshell.api.run("unit.add_conversion_based_unit", model, name="inch")
- area = ifcopenshell.api.run("unit.add_conversion_based_unit", model, name="square foot")
+ length = ifcopenshell.api.unit.add_conversion_based_unit(model, name="inch")
+ area = ifcopenshell.api.unit.add_conversion_based_unit(model, name="square foot")
# Make it our default units, if we are doing an imperial building
- ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
+ ifcopenshell.api.unit.assign_unit(model, units=[length, area])
"""
settings = {"name": name, "conversion_offset": conversion_offset}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py
index 4cf9ca6730..8d4a3130f0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_monetary_unit.py
@@ -36,10 +36,10 @@ def add_monetary_unit(file: ifcopenshell.file, currency: str = "DOLLARYDOO") ->
# If you do all your cost plans in Zimbabwean dollars then nobody
# knows how accurate the numbers are.
- zwl = ifcopenshell.api.run("unit.add_monetary_unit", model, currency="ZWL")
+ zwl = ifcopenshell.api.unit.add_monetary_unit(model, currency="ZWL")
# Make it our default currency
- ifcopenshell.api.run("unit.assign_unit", model, units=[zwl])
+ ifcopenshell.api.unit.assign_unit(model, units=[zwl])
"""
settings = {"currency": currency}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/add_si_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/add_si_unit.py
index 67ce025dd8..56cab159ab 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/add_si_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/add_si_unit.py
@@ -52,11 +52,11 @@ def add_si_unit(
.. code:: python
# Millimeters and square meters
- length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
- area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
+ length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
+ area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
- ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
+ ifcopenshell.api.unit.assign_unit(model, units=[length, area])
"""
settings = {"unit_type": unit_type, "prefix": prefix}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/assign_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/assign_unit.py
index 1e6e1a9cdf..1b9c378c8d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/assign_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/assign_unit.py
@@ -51,20 +51,20 @@ def assign_unit(
.. code:: python
# You need a project before you can assign units.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
# Millimeters and square meters
- length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
- area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
+ length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
+ area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
- ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
+ ifcopenshell.api.unit.assign_unit(model, units=[length, area])
# Alternatively, you may specify without any arguments to
# automatically create millimeters, square meters, and cubic meters
# as a convenience for testing purposes. Sorry imperial folks, we
# prioritise metric here.
- ifcopenshell.api.run("unit.assign_unit", model)
+ ifcopenshell.api.unit.assign_unit(model)
"""
usecase = Usecase()
usecase.file = file
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py
index 888bbde510..4fdfe6ec29 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_monetary_unit.py
@@ -38,10 +38,10 @@ def edit_monetary_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instan
# If you do all your cost plans in Zimbabwean dollars then nobody
# knows how accurate the numbers are.
- zwl = ifcopenshell.api.run("unit.add_monetary_unit", model, currency="ZWL")
+ zwl = ifcopenshell.api.unit.add_monetary_unit(model, currency="ZWL")
# Ah who are we kidding
- ifcopenshell.api.run("unit.edit_monetary_unit", model, unit=zwl, attributes={"Currency": "USD"})
+ ifcopenshell.api.unit.edit_monetary_unit(model, unit=zwl, attributes={"Currency": "USD"})
"""
settings = {"unit": unit, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py
index 72cd618839..e439e2c476 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/edit_named_unit.py
@@ -40,10 +40,10 @@ def edit_named_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance,
.. code:: python
# Boxes of things
- unit = ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="BOXES")
+ unit = ifcopenshell.api.unit.add_context_dependent_unit(model, name="BOXES")
# Uh, crates? Boxes? Whatever.
- ifcopenshell.api.run("unit.edit_named_unit", model, unit=unit, attibutes={"Name": "CRATES"})
+ ifcopenshell.api.unit.edit_named_unit(model, unit=unit, attibutes={"Name": "CRATES"})
"""
settings = {"unit": unit, "attributes": attributes or {}}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py
index eb572aa59c..88cffbc4a0 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py
@@ -36,10 +36,10 @@ def remove_unit(file: ifcopenshell.file, unit: ifcopenshell.entity_instance) ->
.. code:: python
# What?
- unit = ifcopenshell.api.run("unit.add_context_dependent_unit", model, name="HANDFULS")
+ unit = ifcopenshell.api.unit.add_context_dependent_unit(model, name="HANDFULS")
# Yeah maybe not.
- ifcopenshell.api.run("unit.remove_unit", model, unit=unit)
+ ifcopenshell.api.unit.remove_unit(model, unit=unit)
"""
settings = {"unit": unit}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/unit/unassign_unit.py b/src/ifcopenshell-python/ifcopenshell/api/unit/unassign_unit.py
index 0c0b41c2f9..17eee6d4be 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/unit/unassign_unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/unit/unassign_unit.py
@@ -32,17 +32,17 @@ def unassign_unit(file: ifcopenshell.file, units: Optional[list[ifcopenshell.ent
.. code:: python
# You need a project before you can assign units.
- ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
# Millimeters and square meters
- length = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="LENGTHUNIT", prefix="MILLI")
- area = ifcopenshell.api.run("unit.add_si_unit", model, unit_type="AREAUNIT")
+ length = ifcopenshell.api.unit.add_si_unit(model, unit_type="LENGTHUNIT", prefix="MILLI")
+ area = ifcopenshell.api.unit.add_si_unit(model, unit_type="AREAUNIT")
# Make it our default units, if we are doing a metric building
- ifcopenshell.api.run("unit.assign_unit", model, units=[length, area])
+ ifcopenshell.api.unit.assign_unit(model, units=[length, area])
# Actually, we don't need areas.
- ifcopenshell.api.run("unit.unassign_unit", model, units=[area])
+ ifcopenshell.api.unit.unassign_unit(model, units=[area])
"""
settings = {"units": units}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py b/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py
index bdc0422955..0fb7d2e906 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/void/add_filling.py
@@ -45,62 +45,62 @@ def add_filling(
# A bit of preparation, let's create some geometric contexts since
# we want to create some geometry for our wall and opening.
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Create a wall
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's use the "3D Body" representation we created earlier to add a
# new wall-like body geometry, 5 meters long, 3 meters high, and
# 200mm thick
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Create an opening, such as for a service penetration with fire and
# acoustic requirements.
- opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
+ opening = ifcopenshell.api.root.create_entity(model, ifc_class="IfcOpeningElement")
# Let's create an opening representation of a 950mm x 2100mm door.
# Notice how the thickness is greater than the wall thickness, this
# helps resolve floating point resolution errors in 3D.
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=.95, height=2.1, thickness=0.4)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=opening, representation=representation)
# Let's shift our door 1 meter along the wall and 100mm along the
# wall, to create a nice overlap for the opening boolean.
matrix = np.identity(4)
matrix[:,3] = [1, -.1, 0, 0]
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=opening, matrix=matrix)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=opening, matrix=matrix)
# The opening will now void the wall.
- ifcopenshell.api.run("void.add_opening", model, opening=opening, element=wall)
+ ifcopenshell.api.void.add_opening(model, opening=opening, element=wall)
# Create a door
- door = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcDoor")
+ door = ifcopenshell.api.root.create_entity(model, ifc_class="IfcDoor")
# Let's create a door representation of a 950mm x 2100mm door.
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=.95, height=2.1, thickness=0.05)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=door, representation=representation)
# Let's shift our door 1 meter along the wall and 100mm along the
# wall, which lines up with our opening.
matrix = np.identity(4)
matrix[:,3] = [1, .05, 0, 0]
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=door, matrix=matrix)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=door, matrix=matrix)
# The door will now fill the opening.
- ifcopenshell.api.run("void.add_filling", model, opening=opening, element=door)
+ ifcopenshell.api.void.add_filling(model, opening=opening, element=door)
"""
settings = {"opening": opening, "element": element}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/add_opening.py b/src/ifcopenshell-python/ifcopenshell/api/void/add_opening.py
index 67e7f1b1c1..8c739ff0e4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/void/add_opening.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/void/add_opening.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.owner
+import ifcopenshell.api.geometry
import ifcopenshell.guid
import ifcopenshell.util.element
import ifcopenshell.util.placement
@@ -63,44 +64,44 @@ def add_opening(
# A bit of preparation, let's create some geometric contexts since
# we want to create some geometry for our wall and opening.
- model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
- body = ifcopenshell.api.run("context.add_context", model,
+ model3d = ifcopenshell.api.context.add_context(model, context_type="Model")
+ body = ifcopenshell.api.context.add_context(model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
# Create a wall
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's use the "3D Body" representation we created earlier to add a
# new wall-like body geometry, 5 meters long, 3 meters high, and
# 200mm thick
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=5, height=3, thickness=0.2)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=wall, representation=representation)
# Place our wall at the origin
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=wall)
# Create an opening, such as for a service penetration with fire and
# acoustic requirements.
- opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
+ opening = ifcopenshell.api.root.create_entity(model, ifc_class="IfcOpeningElement")
# Let's create an opening representation of a 950mm x 2100mm door.
# Notice how the thickness is greater than the wall thickness, this
# helps resolve floating point resolution errors in 3D.
- representation = ifcopenshell.api.run("geometry.add_wall_representation", model,
+ representation = ifcopenshell.api.geometry.add_wall_representation(model,
context=body, length=.95, height=2.1, thickness=0.4)
- ifcopenshell.api.run("geometry.assign_representation", model,
+ ifcopenshell.api.geometry.assign_representation(model,
product=opening, representation=representation)
# Let's shift our door 1 meter along the wall and 100mm along the
# wall, to create a nice overlap for the opening boolean.
matrix = np.identity(4)
matrix[:,3] = [1, -.1, 0, 0]
- ifcopenshell.api.run("geometry.edit_object_placement", model, product=opening, matrix=matrix)
+ ifcopenshell.api.geometry.edit_object_placement(model, product=opening, matrix=matrix)
# The opening will now void the wall.
- ifcopenshell.api.run("void.add_opening", model, opening=opening, element=wall)
+ ifcopenshell.api.void.add_opening(model, opening=opening, element=wall)
"""
settings = {"opening": opening, "element": element}
@@ -118,7 +119,7 @@ def add_opening(
"IfcRelVoidsElement",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatingBuildingElement": settings["element"],
"RelatedOpeningElement": settings["opening"],
}
@@ -126,8 +127,7 @@ def add_opening(
placement = getattr(settings["opening"], "ObjectPlacement", None)
if placement and placement.is_a("IfcLocalPlacement"):
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
file,
product=settings["opening"],
matrix=ifcopenshell.util.placement.get_local_placement(settings["opening"].ObjectPlacement),
diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py b/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py
index 3cfdd05ce3..af6d28fc6d 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/void/remove_filling.py
@@ -37,20 +37,20 @@ def remove_filling(file: ifcopenshell.file, element: ifcopenshell.entity_instanc
.. code:: python
# Create a wall
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Create an opening, such as for a service penetration with fire and
# acoustic requirements.
- opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
+ opening = ifcopenshell.api.root.create_entity(model, ifc_class="IfcOpeningElement")
# Create a door
- door = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcDoor")
+ door = ifcopenshell.api.root.create_entity(model, ifc_class="IfcDoor")
# The door will now fill the opening.
- ifcopenshell.api.run("void.add_filling", model, opening=opening, element=door)
+ ifcopenshell.api.void.add_filling(model, opening=opening, element=door)
# Not anymore!
- ifcopenshell.api.run("void.remove_filling", model, element=door)
+ ifcopenshell.api.void.remove_filling(model, element=door)
"""
settings = {"element": element}
diff --git a/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py b/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py
index 7217fc627d..21883bcec4 100644
--- a/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py
+++ b/src/ifcopenshell-python/ifcopenshell/api/void/remove_opening.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import ifcopenshell.api
+import ifcopenshell.api.root
import ifcopenshell.util.element
@@ -39,10 +39,10 @@ def remove_opening(file: ifcopenshell.file, opening: ifcopenshell.entity_instanc
# Create an oprhaned opening. Note that an orphaned opening is
# invalid, as an opening can only exist when voiding another
# element.
- opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
+ opening = ifcopenshell.api.root.create_entity(model, ifc_class="IfcOpeningElement")
# Remove it. This brings us back to a valid model.
- ifcopenshell.api.run("void.remove_opening", model, opening=opening)
+ ifcopenshell.api.void.remove_opening(model, opening=opening)
"""
settings = {"opening": opening}
@@ -57,4 +57,4 @@ def remove_opening(file: ifcopenshell.file, opening: ifcopenshell.entity_instanc
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
- ifcopenshell.api.run("root.remove_product", file, product=settings["opening"])
+ ifcopenshell.api.root.remove_product(file, product=settings["opening"])
diff --git a/src/ifcopenshell-python/ifcopenshell/util/generate_pset_templates.py b/src/ifcopenshell-python/ifcopenshell/util/generate_pset_templates.py
index 716f476481..813767b619 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/generate_pset_templates.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/generate_pset_templates.py
@@ -19,7 +19,8 @@
RUN_FROM_DEV_REPO = False
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.project
import ifcopenshell.guid
import ifcopenshell.util.attribute
import glob
@@ -123,7 +124,7 @@ class PsetTemplatesGenerator:
def parse_psets_data(self, schema_name, pset_data_glob, project_name, ifc_output_path):
schema_name = schema_name.upper()
- self.ifc_file = ifcopenshell.api.run("project.create_file", version=schema_name)
+ self.ifc_file = ifcopenshell.api.project.create_file(version=schema_name)
self.units = dict()
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name)
@@ -268,13 +269,13 @@ class PsetTemplatesGenerator:
unit_entity = None
if unit_type in self.ifc_derived_unit_enum:
- # TODO: define derived units if there will be someday api like `ifcopenshell.api.run("unit.add_derived_unit", ...)`
+ # TODO: define derived units if there will be someday api like `ifcopenshell.api.unit.add_derived_unit(...)`
# since creating IfcDerivedUnit is more complex and requiring settting up elements it consists of
# and related IfcNamedUnits
- # unit_entity = ifcopenshell.api.run("unit.add_derived_unit", self.ifc_file, unit_type=unit_type)
+ # unit_entity = ifcopenshell.api.unit.add_derived_unit(self.ifc_file, unit_type=unit_type)
pass
elif unit_type in self.ifc_unit_enum:
- unit_entity = ifcopenshell.api.run("unit.add_si_unit", self.ifc_file, unit_type=unit_type)
+ unit_entity = ifcopenshell.api.unit.add_si_unit(self.ifc_file, unit_type=unit_type)
elif unit_type == "IFCMONETARYUNIT":
self.ifc_entity("IFCMONETARYUNIT", Currency="")
else:
diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py
index 251668aecc..a2c831ca64 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/selector.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py
@@ -19,7 +19,8 @@
import re
import lark
import numpy as np
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.geometry
import ifcopenshell.util
import ifcopenshell.util.attribute
import ifcopenshell.util.fm
@@ -522,9 +523,7 @@ def set_element_value(
return
matrix[coord_i][3] = new_value
- ifcopenshell.api.run(
- "geometry.edit_object_placement", ifc_file, product=element, matrix=matrix, is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(ifc_file, product=element, matrix=matrix, is_si=False)
return
elif isinstance(element, ifcopenshell.entity_instance):
if key == "Name" and element.is_a("IfcMaterialLayerSet"):
@@ -584,9 +583,9 @@ def set_element_value(
if value and not result and len(keys) == i + 2: # The next key is the prop name
if "qto" in key.lower() or "quantity" in key.lower() or "quantities" in key.lower():
- pset = ifcopenshell.api.run("pset.add_qto", ifc_file, product=element, name=key)
+ pset = ifcopenshell.api.pset.add_qto(ifc_file, product=element, name=key)
else:
- pset = ifcopenshell.api.run("pset.add_pset", ifc_file, product=element, name=key)
+ pset = ifcopenshell.api.pset.add_pset(ifc_file, product=element, name=key)
result = {"id": pset.id()}
element = result
@@ -596,16 +595,16 @@ def set_element_value(
for prop, prop_value in element.items():
if key.match(prop):
if pset.is_a("IfcPropertySet") and prop_value != value:
- ifcopenshell.api.run("pset.edit_pset", ifc_file, pset=pset, properties={prop: value})
+ ifcopenshell.api.pset.edit_pset(ifc_file, pset=pset, properties={prop: value})
elif pset.is_a("IfcElementQuantity") and prop_value != float(value):
- ifcopenshell.api.run("pset.edit_qto", ifc_file, qto=pset, properties={prop: float(value)})
+ ifcopenshell.api.pset.edit_qto(ifc_file, qto=pset, properties={prop: float(value)})
elif pset.is_a("IfcPropertySet") and element.get(key, None) != value:
- ifcopenshell.api.run("pset.edit_pset", ifc_file, pset=pset, properties={key: value})
+ ifcopenshell.api.pset.edit_pset(ifc_file, pset=pset, properties={key: value})
elif pset.is_a("IfcElementQuantity"):
try:
value = float(value)
if element.get(key, None) != value:
- ifcopenshell.api.run("pset.edit_qto", ifc_file, qto=pset, properties={key: value})
+ ifcopenshell.api.pset.edit_qto(ifc_file, qto=pset, properties={key: value})
except:
pass
return
diff --git a/src/ifcopenshell-python/ifcopenshell/util/sequence.py b/src/ifcopenshell-python/ifcopenshell/util/sequence.py
index fc661fc07f..61f72b55b5 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/sequence.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/sequence.py
@@ -500,18 +500,18 @@ def get_related_products(
# Let's imagine we are creating a construction schedule. All tasks
# need to be part of a work schedule.
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", model, name="Construction Schedule A")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(model, name="Construction Schedule A")
# Let's create a construction task. Note that the predefined type is
# important to distinguish types of tasks.
- task = ifcopenshell.api.run("sequence.add_task", model,
+ task = ifcopenshell.api.sequence.add_task(model,
work_schedule=schedule, name="Build wall", identification="A", predefined_type="CONSTRUCTION")
# Let's say we have a wall somewhere.
- wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
# Let's construct that wall!
- ifcopenshell.api.run("sequence.assign_product", relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(relating_product=wall, related_object=task)
# This will give us a set with that wall in it.
products = ifcopenshell.util.sequence.get_related_products(related_object=task)
diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py
index 6666da08c6..475aca0f71 100644
--- a/src/ifcopenshell-python/ifcopenshell/util/unit.py
+++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py
@@ -22,7 +22,7 @@ from typing import Iterable, Any, Union, Literal, Optional
import ifcopenshell
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
-import ifcopenshell.api
+import ifcopenshell.api.unit
prefixes = {
"EXA": 1e18,
@@ -815,7 +815,7 @@ def convert_file_length_units(ifc_file: ifcopenshell.file, target_units: str = "
old_length = next(u for u in unit_assignment.Units if getattr(u, "UnitType", None) == "LENGTHUNIT")
if si_unit:
- new_length = ifcopenshell.api.run("unit.add_si_unit", file_patched, unit_type="LENGTHUNIT", prefix=prefix)
+ new_length = ifcopenshell.api.unit.add_si_unit(file_patched, unit_type="LENGTHUNIT", prefix=prefix)
else:
target_units = target_units.lower()
if imperial_types.get(target_units) != "LENGTHUNIT":
@@ -823,7 +823,7 @@ def convert_file_length_units(ifc_file: ifcopenshell.file, target_units: str = "
f'Couldn\'t identify target units "{target_units}". '
'The method supports singular unit names like "CENTIMETER", "METER", "FOOT", etc.'
)
- new_length = ifcopenshell.api.run("unit.add_conversion_based_unit", file_patched, name=target_units)
+ new_length = ifcopenshell.api.unit.add_conversion_based_unit(file_patched, name=target_units)
# support tuple of tuples, as in IfcCartesianPointList3D.CoordList
def convert_value(value):
diff --git a/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py b/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py
index e1036e16e3..f00ff6c1d0 100644
--- a/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py
+++ b/src/ifcopenshell-python/test/api/aggregate/test_assign_object.py
@@ -19,60 +19,64 @@
import numpy
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.unit
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
import ifcopenshell.util.element
import ifcopenshell.util.placement
class TestAssignObject(test.bootstrap.IFC4):
def test_assigning_an_aggregate(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- rel = ifcopenshell.api.run(
- "aggregate.assign_object", self.file, products=[subelement1, subelement2], relating_object=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ rel = ifcopenshell.api.aggregate.assign_object(
+ self.file, products=[subelement1, subelement2], relating_object=element
)
assert ifcopenshell.util.element.get_aggregate(subelement1) == element
assert ifcopenshell.util.element.get_aggregate(subelement2) == element
assert rel.is_a("IfcRelAggregates")
def test_doing_nothing_if_the_aggregate_is_already_assigned(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert len([e for e in self.file]) == total_elements
def test_that_old_aggregate_relationships_are_updated_if_they_still_have_elements(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element1)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement2], relating_object=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element1)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement2], relating_object=element1)
rel = subelement1.Decomposes[0]
assert len(rel.RelatedObjects) == 2
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element2)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element2)
assert len(rel.RelatedObjects) == 1
def test_that_old_aggregate_relationships_are_purged_if_no_more_elements_are_contained(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element1)
rel_id = subelement1.Decomposes[0].id()
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element2)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element2)
with pytest.raises(RuntimeError):
self.file.by_id(rel_id)
def test_assigning_a_container_does_not_shift_object_placements(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element1)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element1)
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -89,37 +93,33 @@ class TestAssignObject(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element1, matrix=matrix1.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1, matrix=matrix1.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element2, matrix=matrix2.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=matrix1.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element2, matrix=matrix2.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=matrix1.copy(), is_si=False
- )
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element2)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element2)
assert subelement.ObjectPlacement.PlacementRelTo.PlacesObject[0] == element2
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), matrix1)
def test_not_updating_placement_if_placement_is_not_relative(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
placement = self.file.createIfcGridPlacement()
subelement.ObjectPlacement = placement
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert subelement.ObjectPlacement == placement
def test_removing_containment_if_it_exists(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- container = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=container)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ container = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=container)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert not ifcopenshell.util.element.get_container(subelement, should_get_direct=True)
diff --git a/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py b/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py
index 8619275fd7..722cccdb93 100644
--- a/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py
+++ b/src/ifcopenshell-python/test/api/aggregate/test_unassign_object.py
@@ -16,38 +16,38 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.aggregate
import ifcopenshell.util.element
class TestUnassignObject(test.bootstrap.IFC4):
def test_unassigning_an_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run(
- "aggregate.assign_object", self.file, products=[subelement1, subelement2], relating_object=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(
+ self.file, products=[subelement1, subelement2], relating_object=element
)
- ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement1, subelement2])
+ ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement1, subelement2])
assert ifcopenshell.util.element.get_aggregate(subelement1) is None
assert ifcopenshell.util.element.get_aggregate(subelement2) is None
def test_the_rel_is_kept_if_there_are_more_decomposed_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement2], relating_object=element)
- ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement1])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement2], relating_object=element)
+ ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement1])
assert len(self.file.by_type("IfcRelAggregates")) == 1
def test_the_rel_is_purged_if_there_are_no_more_decomposed_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement])
assert len(self.file.by_type("IfcRelAggregates")) == 0
diff --git a/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py b/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py
index e5a8b98437..30adbf74c4 100644
--- a/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py
+++ b/src/ifcopenshell-python/test/api/boundary/test_copy_boundary.py
@@ -17,21 +17,22 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.boundary
class TestCopyBoundary(test.bootstrap.IFC4):
def test_run(self):
- boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
- boundary2 = ifcopenshell.api.run("boundary.copy_boundary", self.file, boundary=boundary)
+ boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
+ boundary2 = ifcopenshell.api.boundary.copy_boundary(self.file, boundary=boundary)
assert boundary2.is_a("IfcRelSpaceBoundary")
assert boundary2.GlobalId != boundary.GlobalId
def test_copying_connection_geometry(self):
geometry = self.file.createIfcConnectionSurfaceGeometry()
- boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
+ boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
boundary.ConnectionGeometry = geometry
- boundary2 = ifcopenshell.api.run("boundary.copy_boundary", self.file, boundary=boundary)
+ boundary2 = ifcopenshell.api.boundary.copy_boundary(self.file, boundary=boundary)
assert boundary2.ConnectionGeometry.is_a("IfcConnectionSurfaceGeometry")
assert boundary2.ConnectionGeometry != boundary.ConnectionGeometry
diff --git a/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py b/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py
index cd3b5ff54b..7dea36b2bc 100644
--- a/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py
+++ b/src/ifcopenshell-python/test/api/boundary/test_remove_boundary.py
@@ -17,20 +17,21 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.boundary
class TestRemoveBoundary(test.bootstrap.IFC4):
def test_run(self):
- boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
- ifcopenshell.api.run("boundary.remove_boundary", self.file, boundary=boundary)
+ boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
+ ifcopenshell.api.boundary.remove_boundary(self.file, boundary=boundary)
assert not self.file.by_type("IfcRelSpaceBoundary")
def test_removing_connection_geometry(self):
geometry = self.file.createIfcConnectionSurfaceGeometry()
- boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
+ boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
boundary.ConnectionGeometry = geometry
- ifcopenshell.api.run("boundary.remove_boundary", self.file, boundary=boundary)
+ ifcopenshell.api.boundary.remove_boundary(self.file, boundary=boundary)
assert not self.file.by_type("IfcRelSpaceBoundary")
assert not self.file.by_type("IfcConnectionSurfaceGeometry")
diff --git a/src/ifcopenshell-python/test/api/classification/test_add_classification.py b/src/ifcopenshell-python/test/api/classification/test_add_classification.py
index 0255e1240c..12442255fe 100644
--- a/src/ifcopenshell-python/test/api/classification/test_add_classification.py
+++ b/src/ifcopenshell-python/test/api/classification/test_add_classification.py
@@ -17,20 +17,21 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.classification
class TestAddClassification(test.bootstrap.IFC4):
def test_adding_a_classification(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.classification.add_classification(self.file, classification="Name")
assert self.file.by_type("IfcClassification")[0].Name == "Name"
def test_adding_a_classification_from_a_library(self):
library = ifcopenshell.file()
classification = library.createIfcClassification(Name="Name")
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.classification.add_classification(self.file, classification=classification)
assert self.file.by_type("IfcClassification")[0].Name == "Name"
diff --git a/src/ifcopenshell-python/test/api/classification/test_add_reference.py b/src/ifcopenshell-python/test/api/classification/test_add_reference.py
index ed52b05d35..caf6f5d8af 100644
--- a/src/ifcopenshell-python/test/api/classification/test_add_reference.py
+++ b/src/ifcopenshell-python/test/api/classification/test_add_reference.py
@@ -18,7 +18,8 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.classification
import ifcopenshell.util.classification
@@ -26,12 +27,11 @@ class TestAddReference(test.bootstrap.IFC4):
def test_adding_a_reference(self):
is_ifc2x3 = self.file.schema == "IFC2X3"
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2],
identification="X",
@@ -64,12 +64,11 @@ class TestAddReference(test.bootstrap.IFC4):
classification = library.createIfcClassification(Name="Name")
reference = library.createIfcClassificationReference(Identification="1", ReferencedSource=classification)
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification=classification)
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2],
reference=reference,
@@ -94,16 +93,15 @@ class TestAddReference(test.bootstrap.IFC4):
assert len(rel.RelatedObjects) == 2
def test_adding_a_reference_to_a_resource_and_to_a_root(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
element = self.file.createIfcMaterial()
element2 = self.file.createIfcCostValue()
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
if self.file.schema == "IFC2X3":
with pytest.raises(TypeError):
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2, element3],
identification="X",
@@ -112,8 +110,7 @@ class TestAddReference(test.bootstrap.IFC4):
)
return
else:
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2, element3],
identification="X",
diff --git a/src/ifcopenshell-python/test/api/classification/test_remove_classification.py b/src/ifcopenshell-python/test/api/classification/test_remove_classification.py
index 319384306e..15a8b414cb 100644
--- a/src/ifcopenshell-python/test/api/classification/test_remove_classification.py
+++ b/src/ifcopenshell-python/test/api/classification/test_remove_classification.py
@@ -17,46 +17,45 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.classification
class TestRemoveClassification(test.bootstrap.IFC4):
def test_removing_a_classification(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- ifcopenshell.api.run("classification.remove_classification", self.file, classification=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ ifcopenshell.api.classification.remove_classification(self.file, classification=element)
assert not self.file.by_type("IfcClassification")
def test_removing_a_classification_and_all_of_its_references(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
identification="X",
name="Foobar",
classification=result,
)
- ifcopenshell.api.run("classification.remove_classification", self.file, classification=result)
+ ifcopenshell.api.classification.remove_classification(self.file, classification=result)
assert not self.file.by_type("IfcClassification")
assert not self.file.by_type("IfcClassificationReference")
assert not self.file.by_type("IfcRelAssociatesClassification")
def test_removing_a_classification_and_all_of_its_references_when_associated_with_a_resource(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
element = self.file.create_entity("IfcWall", Name="Wall")
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
identification="X",
name="Foobar",
classification=result,
)
- ifcopenshell.api.run("classification.remove_classification", self.file, classification=result)
+ ifcopenshell.api.classification.remove_classification(self.file, classification=result)
assert not self.file.by_type("IfcClassification")
assert not self.file.by_type("IfcClassificationReference")
if self.file.schema != "IFC2X3":
diff --git a/src/ifcopenshell-python/test/api/classification/test_remove_reference.py b/src/ifcopenshell-python/test/api/classification/test_remove_reference.py
index 8e03fdef4f..3382883af8 100644
--- a/src/ifcopenshell-python/test/api/classification/test_remove_reference.py
+++ b/src/ifcopenshell-python/test/api/classification/test_remove_reference.py
@@ -18,41 +18,40 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.classification
import ifcopenshell.util.classification
class TestRemoveReference(test.bootstrap.IFC4):
def test_removing_a_reference(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- reference = ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ reference = ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2],
identification="X",
name="Foobar",
classification=result,
)
- ifcopenshell.api.run(
- "classification.remove_reference", self.file, products=[element, element2], reference=reference
+ ifcopenshell.api.classification.remove_reference(
+ self.file, products=[element, element2], reference=reference
)
assert len(ifcopenshell.util.classification.get_references(element)) == 0
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
assert len(self.file.by_type("IfcClassificationReference")) == 0
def test_removing_a_reference_from_a_resource_and_from_a_root(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
element = self.file.createIfcMaterial()
element2 = self.file.createIfcCostValue()
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
if self.file.schema == "IFC2X3":
with pytest.raises(TypeError):
- reference = ifcopenshell.api.run(
- "classification.add_reference",
+ reference = ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2, element3],
identification="X",
@@ -61,8 +60,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
)
return
else:
- reference = ifcopenshell.api.run(
- "classification.add_reference",
+ reference = ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2, element3],
identification="X",
@@ -70,8 +68,8 @@ class TestRemoveReference(test.bootstrap.IFC4):
classification=result,
)
- ifcopenshell.api.run(
- "classification.remove_reference", self.file, products=[element, element2, element3], reference=reference
+ ifcopenshell.api.classification.remove_reference(
+ self.file, products=[element, element2, element3], reference=reference
)
assert len(ifcopenshell.util.classification.get_references(element)) == 0
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
@@ -79,13 +77,12 @@ class TestRemoveReference(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcClassificationReference")) == 0
def test_retaining_the_reference_if_still_in_use(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- reference = ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ reference = ifcopenshell.api.classification.add_reference(
self.file,
products=[element, element2, element3],
identification="X",
@@ -93,11 +90,11 @@ class TestRemoveReference(test.bootstrap.IFC4):
classification=result,
)
assert len(self.file.by_type("IfcClassificationReference")) == 1
- ifcopenshell.api.run(
- "classification.remove_reference", self.file, products=[element, element2], reference=reference
+ ifcopenshell.api.classification.remove_reference(
+ self.file, products=[element, element2], reference=reference
)
assert len(self.file.by_type("IfcClassificationReference")) == 1
- ifcopenshell.api.run("classification.remove_reference", self.file, products=[element3], reference=reference)
+ ifcopenshell.api.classification.remove_reference(self.file, products=[element3], reference=reference)
assert len(self.file.by_type("IfcClassificationReference")) == 0
diff --git a/src/ifcopenshell-python/test/api/constraint/test_assign_constraint.py b/src/ifcopenshell-python/test/api/constraint/test_assign_constraint.py
index f881ae9651..d8a24e48a2 100644
--- a/src/ifcopenshell-python/test/api/constraint/test_assign_constraint.py
+++ b/src/ifcopenshell-python/test/api/constraint/test_assign_constraint.py
@@ -16,46 +16,46 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.constraint
import ifcopenshell.util.constraint
class TestAssignConstraint(test.bootstrap.IFC4):
def test_assign_a_constraint(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
assert ifcopenshell.util.constraint.get_constrained_elements(constraint) == {element, element2}
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 1
def test_doing_nothing_if_the_constraint_is_already_assigned(self):
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
assert len([e for e in self.file]) == total_elements
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("constraint.assign_constraint", self.file, products=[element1], constraint=constraint)
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element2, element3], constraint=constraint
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element2, element3], constraint=constraint
)
assert len(rel.RelatedObjects) == 3
diff --git a/src/ifcopenshell-python/test/api/constraint/test_unassign_constraint.py b/src/ifcopenshell-python/test/api/constraint/test_unassign_constraint.py
index 0d8a21b8bf..0114acfa0b 100644
--- a/src/ifcopenshell-python/test/api/constraint/test_unassign_constraint.py
+++ b/src/ifcopenshell-python/test/api/constraint/test_unassign_constraint.py
@@ -16,49 +16,49 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.constraint
import ifcopenshell.util.constraint
class TestUnassignConstraint(test.bootstrap.IFC4):
def test_unassigning_a_constraint(self):
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
- ifcopenshell.api.run(
- "constraint.unassign_constraint", self.file, products=[element, element2], constraint=constraint
+ ifcopenshell.api.constraint.unassign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 0
def test_doing_nothing_if_no_constraint(self):
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "constraint.unassign_constraint", self.file, products=[element, element2], constraint=constraint
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.unassign_constraint(
+ self.file, products=[element, element2], constraint=constraint
)
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
assert ifcopenshell.util.constraint.get_constrained_elements(element2) == set()
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
- constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("constraint.assign_constraint", self.file, products=[element1], constraint=constraint)
+ constraint = ifcopenshell.api.constraint.add_objective(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
- ifcopenshell.api.run(
- "constraint.assign_constraint", self.file, products=[element2, element3], constraint=constraint
+ ifcopenshell.api.constraint.assign_constraint(
+ self.file, products=[element2, element3], constraint=constraint
)
- ifcopenshell.api.run(
- "constraint.unassign_constraint", self.file, products=[element1, element2], constraint=constraint
+ ifcopenshell.api.constraint.unassign_constraint(
+ self.file, products=[element1, element2], constraint=constraint
)
assert rel.RelatedObjects == (element3,)
diff --git a/src/ifcopenshell-python/test/api/context/test_add_context.py b/src/ifcopenshell-python/test/api/context/test_add_context.py
index 2a427ef889..1ae3183697 100644
--- a/src/ifcopenshell-python/test/api/context/test_add_context.py
+++ b/src/ifcopenshell-python/test/api/context/test_add_context.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.context
class TestAddContext(test.bootstrap.IFC4):
def test_adding_a_3d_context(self):
self.file.createIfcProject()
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
assert context.ContextType == "Model"
assert context.is_a() == "IfcGeometricRepresentationContext"
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement3D"
@@ -34,7 +34,7 @@ class TestAddContext(test.bootstrap.IFC4):
def test_adding_a_2d_context(self):
self.file.createIfcProject()
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Plan")
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Plan")
assert context.ContextType == "Plan"
assert context.is_a() == "IfcGeometricRepresentationContext"
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement2D"
@@ -44,7 +44,7 @@ class TestAddContext(test.bootstrap.IFC4):
def test_defaulting_to_3d_with_an_unknown_context_type(self):
self.file.createIfcProject()
- context = ifcopenshell.api.run("context.add_context", self.file)
+ context = ifcopenshell.api.context.add_context(self.file)
assert context.ContextType is None
assert context.is_a() == "IfcGeometricRepresentationContext"
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement3D"
@@ -56,15 +56,15 @@ class TestAddContext(test.bootstrap.IFC4):
def test_adding_a_subcontext(self):
self.test_adding_a_3d_context()
context = self.file.by_type("IfcGeometricRepresentationContext")[0]
- subcontext = ifcopenshell.api.run("context.add_context", self.file, parent=context, target_view="NOTDEFINED")
+ subcontext = ifcopenshell.api.context.add_context(self.file, parent=context, target_view="NOTDEFINED")
assert subcontext.is_a("IfcGeometricRepresentationSubContext")
assert subcontext.TargetView == "NOTDEFINED"
def test_adding_a_subcontext_with_an_optional_identifier_specified(self):
self.test_adding_a_3d_context()
context = self.file.by_type("IfcGeometricRepresentationContext")[0]
- subcontext = ifcopenshell.api.run(
- "context.add_context", self.file, parent=context, target_view="NOTDEFINED", context_identifier="Body"
+ subcontext = ifcopenshell.api.context.add_context(
+ self.file, parent=context, target_view="NOTDEFINED", context_identifier="Body"
)
assert subcontext.is_a("IfcGeometricRepresentationSubContext")
assert subcontext.TargetView == "NOTDEFINED"
diff --git a/src/ifcopenshell-python/test/api/context/test_edit_context.py b/src/ifcopenshell-python/test/api/context/test_edit_context.py
index 87fd8ddbd7..f138b649e1 100644
--- a/src/ifcopenshell-python/test/api/context/test_edit_context.py
+++ b/src/ifcopenshell-python/test/api/context/test_edit_context.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.context
class TestEditContext(test.bootstrap.IFC4):
def test_editing_a_context(self):
context = self.file.createIfcGeometricRepresentationContext()
- ifcopenshell.api.run(
- "context.edit_context",
+ ifcopenshell.api.context.edit_context(
self.file,
context=context,
attributes={
@@ -41,8 +40,7 @@ class TestEditContext(test.bootstrap.IFC4):
def test_editing_a_subcontext(self):
subcontext = self.file.createIfcGeometricRepresentationSubcontext()
- ifcopenshell.api.run(
- "context.edit_context",
+ ifcopenshell.api.context.edit_context(
self.file,
context=subcontext,
attributes={
diff --git a/src/ifcopenshell-python/test/api/context/test_remove_context.py b/src/ifcopenshell-python/test/api/context/test_remove_context.py
index 682990e154..9bc43f64d4 100644
--- a/src/ifcopenshell-python/test/api/context/test_remove_context.py
+++ b/src/ifcopenshell-python/test/api/context/test_remove_context.py
@@ -17,20 +17,20 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.context
class TestRemoveContext(test.bootstrap.IFC4):
def test_removing_a_context(self):
context = self.file.createIfcGeometricRepresentationContext()
- ifcopenshell.api.run("context.remove_context", self.file, context=context)
+ ifcopenshell.api.context.remove_context(self.file, context=context)
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 0
def test_removing_a_context_with_subcontexts(self):
context = self.file.createIfcGeometricRepresentationContext()
subcontext = self.file.createIfcGeometricRepresentationSubcontext()
subcontext.ParentContext = context
- ifcopenshell.api.run("context.remove_context", self.file, context=context)
+ ifcopenshell.api.context.remove_context(self.file, context=context)
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 0
def test_removing_a_subcontext_and_reassigning_references_to_its_parent(self):
@@ -41,7 +41,7 @@ class TestRemoveContext(test.bootstrap.IFC4):
if self.file.schema != "IFC2X3":
projected_crs = self.file.createIfcProjectedCRS()
map_conversion = self.file.createIfcMapConversion(SourceCRS=subcontext, TargetCRS=projected_crs)
- ifcopenshell.api.run("context.remove_context", self.file, context=subcontext)
+ ifcopenshell.api.context.remove_context(self.file, context=subcontext)
assert len(self.file.by_type("IfcGeometricRepresentationSubcontext")) == 0
assert representation in self.file.get_inverse(context)
if self.file.schema != "IFC2X3":
@@ -51,7 +51,7 @@ class TestRemoveContext(test.bootstrap.IFC4):
def test_removing_a_context_with_references(self):
context = self.file.createIfcGeometricRepresentationContext()
representation = self.file.createIfcRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("context.remove_context", self.file, context=context)
+ ifcopenshell.api.context.remove_context(self.file, context=context)
assert len([e for e in self.file]) == 0
diff --git a/src/ifcopenshell-python/test/api/control/test_assign_control.py b/src/ifcopenshell-python/test/api/control/test_assign_control.py
index e8d63d5d6f..e607e53ef4 100644
--- a/src/ifcopenshell-python/test/api/control/test_assign_control.py
+++ b/src/ifcopenshell-python/test/api/control/test_assign_control.py
@@ -17,32 +17,33 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
+import ifcopenshell.api.control
class TestAssignControl(test.bootstrap.IFC4):
def test_run(self):
wall = self.file.createIfcWall()
- control = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
+ control = ifcopenshell.api.cost.add_cost_schedule(self.file)
# simple assignment
- relation = ifcopenshell.api.run(
- "control.assign_control", self.file, relating_control=control, related_object=wall
+ relation = ifcopenshell.api.control.assign_control(
+ self.file, relating_control=control, related_object=wall
)
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
assert relation.RelatingControl == control
assert relation.RelatedObjects == (wall,)
# trying to establish existing relationship
- relation = ifcopenshell.api.run(
- "control.assign_control", self.file, relating_control=control, related_object=wall
+ relation = ifcopenshell.api.control.assign_control(
+ self.file, relating_control=control, related_object=wall
)
assert relation is None
# assigning same control to another object
wall1 = self.file.createIfcWall()
- relation = ifcopenshell.api.run(
- "control.assign_control", self.file, relating_control=control, related_object=wall1
+ relation = ifcopenshell.api.control.assign_control(
+ self.file, relating_control=control, related_object=wall1
)
assert relation is not None
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
diff --git a/src/ifcopenshell-python/test/api/control/test_unassign_control.py b/src/ifcopenshell-python/test/api/control/test_unassign_control.py
index c85ee05765..2037556a76 100644
--- a/src/ifcopenshell-python/test/api/control/test_unassign_control.py
+++ b/src/ifcopenshell-python/test/api/control/test_unassign_control.py
@@ -17,28 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
+import ifcopenshell.api.control
class TestUnassignControl(test.bootstrap.IFC4):
def test_run(self):
wall = self.file.createIfcWall()
- control = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
+ control = ifcopenshell.api.cost.add_cost_schedule(self.file)
# assign and unassign
- relation = ifcopenshell.api.run(
- "control.assign_control", self.file, relating_control=control, related_object=wall
+ relation = ifcopenshell.api.control.assign_control(
+ self.file, relating_control=control, related_object=wall
)
- ifcopenshell.api.run("control.unassign_control", self.file, relating_control=control, related_object=wall)
+ ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall)
assert len(self.file.by_type("IfcRelAssignsToControl")) == 0
# 1 control 2 related objects
wall1 = self.file.createIfcWall()
- relation = ifcopenshell.api.run(
- "control.assign_control", self.file, relating_control=control, related_object=wall
+ relation = ifcopenshell.api.control.assign_control(
+ self.file, relating_control=control, related_object=wall
)
- ifcopenshell.api.run("control.assign_control", self.file, relating_control=control, related_object=wall1)
- ifcopenshell.api.run("control.unassign_control", self.file, relating_control=control, related_object=wall1)
+ ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
+ ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall1)
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
assert relation.RelatedObjects == (wall,)
diff --git a/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py b/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py
index b2bec35bbf..c2a3762e78 100644
--- a/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py
+++ b/src/ifcopenshell-python/test/api/cost/test_add_cost_item.py
@@ -17,22 +17,22 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
import ifcopenshell.util.element
class TestAddCostItem(test.bootstrap.IFC4):
def test_add_a_cost_item(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
assert item1.is_a("IfcCostItem")
assert item1.HasAssignments[0].is_a("IfcRelAssignsToControl")
assert item1.HasAssignments[0].RelatingControl == schedule
def test_add_a_sub_cost_item(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
assert item2.is_a("IfcCostItem")
assert ifcopenshell.util.element.get_nest(item2) == item1
diff --git a/src/ifcopenshell-python/test/api/cost/test_add_cost_item_quantity.py b/src/ifcopenshell-python/test/api/cost/test_add_cost_item_quantity.py
index 49660dc0a9..7b803a000b 100644
--- a/src/ifcopenshell-python/test/api/cost/test_add_cost_item_quantity.py
+++ b/src/ifcopenshell-python/test/api/cost/test_add_cost_item_quantity.py
@@ -17,22 +17,24 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
+import ifcopenshell.api.root
+import ifcopenshell.api.control
class TestAddCostItemQuantity(test.bootstrap.IFC4):
def test_run(self):
schema = ifcopenshell.schema_by_name(self.file.schema)
quantity_types = [t.name() for t in schema.declaration_by_name("IfcPhysicalSimpleQuantity").subtypes()]
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
- item = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("control.assign_control", self.file, relating_control=item, related_object=wall)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file)
+ item = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.control.assign_control(self.file, relating_control=item, related_object=wall)
quantities = []
for quantity_type in quantity_types:
- quantity = ifcopenshell.api.run(
- "cost.add_cost_item_quantity", self.file, cost_item=item, ifc_class=quantity_type
+ quantity = ifcopenshell.api.cost.add_cost_item_quantity(
+ self.file, cost_item=item, ifc_class=quantity_type
)
assert quantity.is_a(quantity_type)
assert quantity.Name == "Unnamed"
diff --git a/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py b/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py
index 5646b67601..019bc2b6b4 100644
--- a/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py
+++ b/src/ifcopenshell-python/test/api/cost/test_add_cost_schedule.py
@@ -17,18 +17,18 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
class TestAddCostSchedule(test.bootstrap.IFC4):
def test_add_a_cost_schedule(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
assert schedule.is_a("IfcCostSchedule")
assert schedule.Name == "Foo"
assert schedule.PredefinedType == "BUDGET"
def test_adding_a_userdefined_type(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="FOO")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="FOO")
assert schedule.is_a("IfcCostSchedule")
assert schedule.Name == "Foo"
assert schedule.PredefinedType == "USERDEFINED"
diff --git a/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py b/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py
index 96b7a11657..b581afffbc 100644
--- a/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py
+++ b/src/ifcopenshell-python/test/api/cost/test_remove_cost_item.py
@@ -17,31 +17,31 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.cost
class TestRemoveCostItem(test.bootstrap.IFC4):
def test_remove_a_cost_item(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item1)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item1)
assert not self.file.by_type("IfcCostItem")
assert not self.file.by_type("IfcRelAssignsToControl")
def test_remove_a_sub_cost_item(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
- ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item2)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
+ ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item2)
assert self.file.by_type("IfcCostItem") == [item1]
assert self.file.by_type("IfcRelAssignsToControl")
assert not self.file.by_type("IfcRelNests")
def test_remove_a_parent_cost_item(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
- ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item1)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
+ ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item1)
assert not self.file.by_type("IfcCostItem")
assert not self.file.by_type("IfcRelAssignsToControl")
assert not self.file.by_type("IfcRelNests")
diff --git a/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py b/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py
index 7e86eabe7b..309f4b0906 100644
--- a/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py
+++ b/src/ifcopenshell-python/test/api/cost/test_remove_cost_schedule.py
@@ -18,19 +18,20 @@
import test.bootstrap
import ifcopenshell.api
+import ifcopenshell.api.cost
class TestRemoveCostSchedule(test.bootstrap.IFC4):
def test_remove_a_cost_schedule(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
- ifcopenshell.api.run("cost.remove_cost_schedule", self.file, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
+ ifcopenshell.api.cost.remove_cost_schedule(self.file, cost_schedule=schedule)
assert not self.file.by_type("IfcCostSchedule")
def test_remove_a_schedule_with_items(self):
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
- item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
- ifcopenshell.api.run("cost.remove_cost_schedule", self.file, cost_schedule=schedule)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
+ item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
+ ifcopenshell.api.cost.remove_cost_schedule(self.file, cost_schedule=schedule)
assert not self.file.by_type("IfcCostSchedule")
assert not self.file.by_type("IfcCostItem")
assert not self.file.by_type("IfcRelNests")
diff --git a/src/ifcopenshell-python/test/api/document/test_add_information.py b/src/ifcopenshell-python/test/api/document/test_add_information.py
index dcb7eacdb4..8dc687652b 100644
--- a/src/ifcopenshell-python/test/api/document/test_add_information.py
+++ b/src/ifcopenshell-python/test/api/document/test_add_information.py
@@ -17,19 +17,19 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.document
class TestAddInformation(test.bootstrap.IFC4):
def test_adding_information(self):
project = self.file.createIfcProject()
- element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
+ element = ifcopenshell.api.document.add_information(self.file, parent=None)
assert element.is_a("IfcDocumentInformation")
assert len(self.file.by_type("IfcDocumentInformation")) == 1
def test_adding_information_to_the_project(self):
project = self.file.createIfcProject()
- element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
+ element = ifcopenshell.api.document.add_information(self.file, parent=None)
rel = self.file.by_type("IfcRelAssociatesDocument")[0]
assert rel.is_a("IfcRelAssociatesDocument")
assert rel.RelatingDocument == element
@@ -37,13 +37,13 @@ class TestAddInformation(test.bootstrap.IFC4):
def test_adding_a_subdocument(self):
project = self.file.createIfcProject()
- parent = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- element = ifcopenshell.api.run("document.add_information", self.file, parent=parent)
+ parent = ifcopenshell.api.document.add_information(self.file, parent=None)
+ element = ifcopenshell.api.document.add_information(self.file, parent=parent)
assert element.is_a("IfcDocumentInformation")
assert len(self.file.by_type("IfcDocumentInformation")) == 2
assert element.IsPointedTo[0].RelatingDocument == parent
assert parent.IsPointer[0].RelatedDocuments[0] == element
- element2 = ifcopenshell.api.run("document.add_information", self.file, parent=parent)
+ element2 = ifcopenshell.api.document.add_information(self.file, parent=parent)
assert element in parent.IsPointer[0].RelatedDocuments
assert element2 in parent.IsPointer[0].RelatedDocuments
diff --git a/src/ifcopenshell-python/test/api/document/test_add_reference.py b/src/ifcopenshell-python/test/api/document/test_add_reference.py
index 6cccd86d27..a0420a6d15 100644
--- a/src/ifcopenshell-python/test/api/document/test_add_reference.py
+++ b/src/ifcopenshell-python/test/api/document/test_add_reference.py
@@ -17,19 +17,19 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.document
class TestAddReference(test.bootstrap.IFC4):
def test_adding_a_reference(self):
- element = ifcopenshell.api.run("document.add_reference", self.file, information=None)
+ element = ifcopenshell.api.document.add_reference(self.file, information=None)
assert element.is_a("IfcDocumentReference")
assert len(self.file.by_type("IfcDocumentReference")) == 1
def test_adding_a_reference_to_an_information(self):
self.file.createIfcProject()
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- element = ifcopenshell.api.run("document.add_reference", self.file, information=information)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ element = ifcopenshell.api.document.add_reference(self.file, information=information)
assert element.is_a("IfcDocumentReference")
assert len(self.file.by_type("IfcDocumentReference")) == 1
ifc2x3 = self.file.schema == "IFC2X3"
diff --git a/src/ifcopenshell-python/test/api/document/test_assign_document.py b/src/ifcopenshell-python/test/api/document/test_assign_document.py
index 32d584ac51..2a3051fe4b 100644
--- a/src/ifcopenshell-python/test/api/document/test_assign_document.py
+++ b/src/ifcopenshell-python/test/api/document/test_assign_document.py
@@ -17,23 +17,24 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.document
import ifcopenshell.util.element
class TestAssignDocument(test.bootstrap.IFC4):
def test_assigning_a_document(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
- ifcopenshell.api.run("document.assign_document", self.file, products=[element], document=reference)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ reference = ifcopenshell.api.document.add_reference(self.file, information=None)
+ ifcopenshell.api.document.assign_document(self.file, products=[element], document=reference)
assert element.HasAssociations[0].RelatingDocument == reference
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element}
def test_assigning_multiple_documents(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
- ifcopenshell.api.run("document.assign_document", self.file, products=[element, element2], document=reference)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ reference = ifcopenshell.api.document.add_reference(self.file, information=None)
+ ifcopenshell.api.document.assign_document(self.file, products=[element, element2], document=reference)
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element, element2}
diff --git a/src/ifcopenshell-python/test/api/document/test_remove_information.py b/src/ifcopenshell-python/test/api/document/test_remove_information.py
index 7615a6e277..69e87faece 100644
--- a/src/ifcopenshell-python/test/api/document/test_remove_information.py
+++ b/src/ifcopenshell-python/test/api/document/test_remove_information.py
@@ -17,45 +17,45 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.document
class TestRemoveInformation(test.bootstrap.IFC4):
def test_remove_information(self):
self.file.createIfcProject()
- element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- ifcopenshell.api.run("document.remove_information", self.file, information=element)
+ element = ifcopenshell.api.document.add_information(self.file, parent=None)
+ ifcopenshell.api.document.remove_information(self.file, information=element)
assert len(self.file.by_type("IfcDocumentInformation")) == 0
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
def test_removing_all_references_of_an_information(self):
self.file.createIfcProject()
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- ifcopenshell.api.run("document.add_reference", self.file, information=information)
- ifcopenshell.api.run("document.remove_information", self.file, information=information)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ ifcopenshell.api.document.add_reference(self.file, information=information)
+ ifcopenshell.api.document.remove_information(self.file, information=information)
assert len(self.file.by_type("IfcDocumentInformation")) == 0
assert len(self.file.by_type("IfcDocumentReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
# test removing relationship to another information if it was the only relating element
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- information1 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
- information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ information1 = ifcopenshell.api.document.add_information(self.file, parent=information)
+ information2 = ifcopenshell.api.document.add_information(self.file, parent=information)
- ifcopenshell.api.run("document.remove_information", self.file, information=information1)
+ ifcopenshell.api.document.remove_information(self.file, information=information1)
assert len(self.file.by_type("IfcDocumentInformation")) == 2
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 1
- ifcopenshell.api.run("document.remove_information", self.file, information=information2)
+ ifcopenshell.api.document.remove_information(self.file, information=information2)
assert len(self.file.by_type("IfcDocumentInformation")) == 1
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
def test_removing_all_subdocuments_and_their_references_too(self):
self.file.createIfcProject()
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
- ifcopenshell.api.run("document.add_reference", self.file, information=information2)
- ifcopenshell.api.run("document.remove_information", self.file, information=information)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ information2 = ifcopenshell.api.document.add_information(self.file, parent=information)
+ ifcopenshell.api.document.add_reference(self.file, information=information2)
+ ifcopenshell.api.document.remove_information(self.file, information=information)
assert len(self.file.by_type("IfcDocumentInformation")) == 0
assert len(self.file.by_type("IfcDocumentReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
diff --git a/src/ifcopenshell-python/test/api/document/test_remove_reference.py b/src/ifcopenshell-python/test/api/document/test_remove_reference.py
index 8fc96200ab..dd5fde6602 100644
--- a/src/ifcopenshell-python/test/api/document/test_remove_reference.py
+++ b/src/ifcopenshell-python/test/api/document/test_remove_reference.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.document
class TestRemoveReference(test.bootstrap.IFC4):
def test_removing_reference(self):
project = self.file.createIfcProject()
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=information)
- ifcopenshell.api.run("document.remove_reference", self.file, reference=reference)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ reference = ifcopenshell.api.document.add_reference(self.file, information=information)
+ ifcopenshell.api.document.remove_reference(self.file, reference=reference)
assert len(self.file.by_type("IfcDocumentReference")) == 0
assert len(self.file.by_type("IfcDocumentInformation")) == 1
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
@@ -33,11 +33,11 @@ class TestRemoveReference(test.bootstrap.IFC4):
def test_removing_a_reference_assigned_to_an_object(self):
project = self.file.createIfcProject()
wall = self.file.createIfcWall()
- information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=information)
- ifcopenshell.api.run("document.assign_document", self.file, products=[wall], document=reference)
+ information = ifcopenshell.api.document.add_information(self.file, parent=None)
+ reference = ifcopenshell.api.document.add_reference(self.file, information=information)
+ ifcopenshell.api.document.assign_document(self.file, products=[wall], document=reference)
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 2
- ifcopenshell.api.run("document.remove_reference", self.file, reference=reference)
+ ifcopenshell.api.document.remove_reference(self.file, reference=reference)
assert len(self.file.by_type("IfcDocumentReference")) == 0
assert len(self.file.by_type("IfcDocumentInformation")) == 1
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
diff --git a/src/ifcopenshell-python/test/api/document/test_unassign_document.py b/src/ifcopenshell-python/test/api/document/test_unassign_document.py
index bce6c8d6a1..a8fecd8ad2 100644
--- a/src/ifcopenshell-python/test/api/document/test_unassign_document.py
+++ b/src/ifcopenshell-python/test/api/document/test_unassign_document.py
@@ -17,28 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.document
import ifcopenshell.util.element
class TestUnassignDocument(test.bootstrap.IFC4):
def test_unassigning_a_document(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
- ifcopenshell.api.run("document.assign_document", self.file, products=[element], document=reference)
- ifcopenshell.api.run("document.unassign_document", self.file, products=[element], document=reference)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ reference = ifcopenshell.api.document.add_reference(self.file, information=None)
+ ifcopenshell.api.document.assign_document(self.file, products=[element], document=reference)
+ ifcopenshell.api.document.unassign_document(self.file, products=[element], document=reference)
assert not element.HasAssociations
assert not len(self.file.by_type("IfcRelAssociatesDocument"))
def test_unassigning_a_document_used_by_multiple_entities(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
- ifcopenshell.api.run(
- "document.assign_document", self.file, products=[element, element2, element3], document=reference
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ reference = ifcopenshell.api.document.add_reference(self.file, information=None)
+ ifcopenshell.api.document.assign_document(
+ self.file, products=[element, element2, element3], document=reference
)
- ifcopenshell.api.run("document.unassign_document", self.file, products=[element, element2], document=reference)
+ ifcopenshell.api.document.unassign_document(self.file, products=[element, element2], document=reference)
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element3}
diff --git a/src/ifcopenshell-python/test/api/drawing/test_assign_product.py b/src/ifcopenshell-python/test/api/drawing/test_assign_product.py
index 12e57b7435..2a0bcf4421 100644
--- a/src/ifcopenshell-python/test/api/drawing/test_assign_product.py
+++ b/src/ifcopenshell-python/test/api/drawing/test_assign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.drawing
class TestAssignProduct(test.bootstrap.IFC4):
@@ -25,16 +25,16 @@ class TestAssignProduct(test.bootstrap.IFC4):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
label2 = self.file.createIfcAnnotation()
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
assert wall.ReferencedBy[0].RelatedObjects == (label,)
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label2)
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label2)
assert wall.ReferencedBy[0].RelatedObjects == (label, label2)
def test_not_assigning_twice(self):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
assert len(wall.ReferencedBy) == 1
assert wall.ReferencedBy[0].RelatedObjects == (label,)
diff --git a/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py b/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py
index 9da51a93e9..410c11ce7a 100644
--- a/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py
+++ b/src/ifcopenshell-python/test/api/drawing/test_edit_text_literal.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.drawing
class TestEditTextLiteral(test.bootstrap.IFC4):
def test_run(self):
text = self.file.createIfcTextLiteralWithExtent()
- ifcopenshell.api.run(
- "drawing.edit_text_literal",
+ ifcopenshell.api.drawing.edit_text_literal(
self.file,
text_literal=text,
attributes={
diff --git a/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py b/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py
index c23e978b1c..b8b049ca51 100644
--- a/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py
+++ b/src/ifcopenshell-python/test/api/drawing/test_unassign_product.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.drawing
class TestUnassignProduct(test.bootstrap.IFC4):
def test_unassigning_a_product(self):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
- ifcopenshell.api.run("drawing.unassign_product", self.file, relating_product=wall, related_object=label)
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
+ ifcopenshell.api.drawing.unassign_product(self.file, relating_product=wall, related_object=label)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
diff --git a/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py b/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py
index 7f4dd68b00..04b829b264 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_add_boolean.py
@@ -17,23 +17,24 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.context
+import ifcopenshell.api.geometry
import numpy as np
class TestAddBoolean(test.bootstrap.IFC4):
def test_returning_ifc_boolean_clipping_result(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- body = ifcopenshell.api.run(
- "context.add_context",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ model = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ body = ifcopenshell.api.context.add_context(
self.file,
context_type="Model",
context_identifier="Body",
target_view="MODEL_VIEW",
parent=model,
)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
profile = self.file.create_entity(
"IfcIShapeProfileDef",
@@ -45,12 +46,10 @@ class TestAddBoolean(test.bootstrap.IFC4):
FlangeThickness=8,
FilletRadius=12,
)
- rep = ifcopenshell.api.run(
- "geometry.add_profile_representation", self.file, context=body, profile=profile, depth=5
- )
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
+ rep = ifcopenshell.api.geometry.add_profile_representation(self.file, context=body, profile=profile, depth=5)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
- ifcopenshell.api.run("geometry.add_boolean", self.file, representation=rep, matrix=np.eye(4))
+ ifcopenshell.api.geometry.add_boolean(self.file, representation=rep, matrix=np.eye(4))
assert rep.Items[0].is_a() == "IfcBooleanClippingResult"
assert rep.RepresentationType == "Clipping"
diff --git a/src/ifcopenshell-python/test/api/geometry/test_assign_representation.py b/src/ifcopenshell-python/test/api/geometry/test_assign_representation.py
index 3a33261107..06f0e28485 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_assign_representation.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_assign_representation.py
@@ -18,41 +18,44 @@
import test.bootstrap
import ifcopenshell.api
+import ifcopenshell.api.type
+import ifcopenshell.api.root
+import ifcopenshell.api.geometry
class TestAssignRepresentation(test.bootstrap.IFC4):
def test_assigning_to_a_product(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rep = self.file.createIfcShapeRepresentation()
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
assert wall.Representation.Representations == (rep,)
def test_assigning_to_a_product_with_existing_representations(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rep = self.file.createIfcShapeRepresentation()
rep2 = self.file.createIfcShapeRepresentation()
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
assert wall.Representation.Representations == (rep, rep2)
def test_assigning_to_a_type_product(self):
- walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
rep = self.file.createIfcShapeRepresentation()
rep2 = self.file.createIfcShapeRepresentation()
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
assert walltype.RepresentationMaps[1].MappedRepresentation == rep2
def test_assigning_to_a_type_will_map_representations_to_instances(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
assert wall.Representation.Representations[0].Items[0].MappingSource == walltype.RepresentationMaps[0]
@@ -65,13 +68,13 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
+ walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
@@ -82,10 +85,10 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
def test_assigning_to_an_instance_with_a_nongeometric_type_only_adds_it_to_the_instance(self):
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
+ walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
assert wall.Representation.Representations[0].RepresentationType != "MappedRepresentation"
assert wall.Representation.Representations[0] == rep
assert not walltype.RepresentationMaps
diff --git a/src/ifcopenshell-python/test/api/geometry/test_connect_element.py b/src/ifcopenshell-python/test/api/geometry/test_connect_element.py
index 8550b7b016..240976463b 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_connect_element.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_connect_element.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.geometry
class TestConnectElement(test.bootstrap.IFC4):
def test_connecting_an_element(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "geometry.connect_element",
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.geometry.connect_element(
self.file,
relating_element=wall1,
related_element=wall2,
@@ -37,10 +37,9 @@ class TestConnectElement(test.bootstrap.IFC4):
assert rel.Description == "FOOBAR"
def test_reconnecting_an_element_changes_the_description(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "geometry.connect_element",
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.geometry.connect_element(
self.file,
relating_element=wall1,
related_element=wall2,
@@ -52,8 +51,7 @@ class TestConnectElement(test.bootstrap.IFC4):
assert rel.Description == "FOOBAR"
total_elements = len([e for e in self.file])
- rel = ifcopenshell.api.run(
- "geometry.connect_element",
+ rel = ifcopenshell.api.geometry.connect_element(
self.file,
relating_element=wall1,
related_element=wall2,
@@ -63,10 +61,9 @@ class TestConnectElement(test.bootstrap.IFC4):
assert rel.Description == "FOOBAZ"
def test_reconnecting_and_changing_the_order(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "geometry.connect_element",
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.geometry.connect_element(
self.file,
relating_element=wall1,
related_element=wall2,
@@ -75,9 +72,7 @@ class TestConnectElement(test.bootstrap.IFC4):
assert rel.RelatingElement == wall1
assert rel.RelatedElement == wall2
- total_elements = len([e for e in self.file])
- rel = ifcopenshell.api.run(
- "geometry.connect_element",
+ rel = ifcopenshell.api.geometry.connect_element(
self.file,
relating_element=wall2,
related_element=wall1,
diff --git a/src/ifcopenshell-python/test/api/geometry/test_connect_path.py b/src/ifcopenshell-python/test/api/geometry/test_connect_path.py
index 468c38754a..634eb1b45e 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_connect_path.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_connect_path.py
@@ -17,13 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.geometry
class TestConnectPath(test.bootstrap.IFC4):
def test_connecting_a_path(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel = self.connect_path(wall1, wall2, "ATSTART", "ATEND", description="MITRE")
assert rel.is_a("IfcRelConnectsPathElements")
assert rel.RelatingElement == wall1
@@ -33,34 +34,34 @@ class TestConnectPath(test.bootstrap.IFC4):
assert rel.Description == "MITRE"
def test_doing_nothing_if_the_element_is_already_connected(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
self.connect_path(wall1, wall2)
total_elements = len([e for e in self.file])
self.connect_path(wall1, wall2)
assert len([e for e in self.file]) == total_elements
def test_updating_the_connection_type_if_already_connected(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
total_elements = len([e for e in self.file])
rel = self.connect_path(wall1, wall2, "ATSTART")
assert rel.RelatingConnectionType == "ATSTART"
assert rel.RelatedConnectionType == "NOTDEFINED"
def test_preventing_cyclical_connections(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall2, related_element=wall1)
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall2, related_element=wall1)
assert len([e for e in self.file]) == total_elements
def test_a_relating_element_can_have_multiple_path_connections(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
@@ -74,57 +75,57 @@ class TestConnectPath(test.bootstrap.IFC4):
assert rel2.RelatedConnectionType == "ATSTART"
def test_a_element_can_only_have_up_to_one_start_or_end_connections(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
rel2 = self.connect_path(wall1, wall3, "ATSTART", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall1, wall2, "ATEND", "ATEND")
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATSTART")
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
self.file = ifcopenshell.file()
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATEND")
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
@@ -137,8 +138,7 @@ class TestConnectPath(test.bootstrap.IFC4):
related_connection="NOTDEFINED",
description=None,
):
- return ifcopenshell.api.run(
- "geometry.connect_path",
+ return ifcopenshell.api.geometry.connect_path(
self.file,
relating_element=relating_element,
related_element=related_element,
diff --git a/src/ifcopenshell-python/test/api/geometry/test_disconnect_element.py b/src/ifcopenshell-python/test/api/geometry/test_disconnect_element.py
index 2920231624..4bf8dfbbc8 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_disconnect_element.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_disconnect_element.py
@@ -17,22 +17,23 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.geometry
class TestDisconnectElement(test.bootstrap.IFC4):
def test_disconnecting_an_element(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_element", self.file, relating_element=wall1, related_element=wall2)
- ifcopenshell.api.run("geometry.disconnect_element", self.file, relating_element=wall1, related_element=wall2)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_element(self.file, relating_element=wall1, related_element=wall2)
+ ifcopenshell.api.geometry.disconnect_element(self.file, relating_element=wall1, related_element=wall2)
assert not self.file.by_type("IfcRelConnectsElements")
def test_order_does_not_matter(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_element", self.file, relating_element=wall1, related_element=wall2)
- ifcopenshell.api.run("geometry.disconnect_element", self.file, relating_element=wall2, related_element=wall1)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_element(self.file, relating_element=wall1, related_element=wall2)
+ ifcopenshell.api.geometry.disconnect_element(self.file, relating_element=wall2, related_element=wall1)
assert not self.file.by_type("IfcRelConnectsElements")
diff --git a/src/ifcopenshell-python/test/api/geometry/test_disconnect_path.py b/src/ifcopenshell-python/test/api/geometry/test_disconnect_path.py
index a09eba8725..fdb0c013d8 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_disconnect_path.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_disconnect_path.py
@@ -17,56 +17,55 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.geometry
class TestDisconnectPath(test.bootstrap.IFC4):
def test_disconnecting_a_path(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
- ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall1, related_element=wall2)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
+ ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall1, related_element=wall2)
assert not self.file.by_type("IfcRelConnectsPathElements")
def test_disconnecting_by_connection_type(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "geometry.connect_path",
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(
self.file,
relating_element=wall1,
related_element=wall2,
relating_connection="ATSTART",
related_connection="ATEND",
)
- ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall1, connection_type="ATEND")
+ ifcopenshell.api.geometry.disconnect_path(self.file, element=wall1, connection_type="ATEND")
assert self.file.by_type("IfcRelConnectsPathElements")
- ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall1, connection_type="ATSTART")
+ ifcopenshell.api.geometry.disconnect_path(self.file, element=wall1, connection_type="ATSTART")
assert not self.file.by_type("IfcRelConnectsPathElements")
- ifcopenshell.api.run(
- "geometry.connect_path",
+ ifcopenshell.api.geometry.connect_path(
self.file,
relating_element=wall1,
related_element=wall2,
relating_connection="ATSTART",
related_connection="ATEND",
)
- ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall2, connection_type="ATEND")
+ ifcopenshell.api.geometry.disconnect_path(self.file, element=wall2, connection_type="ATEND")
assert not self.file.by_type("IfcRelConnectsPathElements")
def test_doing_nothing_if_there_is_no_connection(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall1, related_element=wall2)
+ ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall1, related_element=wall2)
assert len([e for e in self.file]) == total_elements
def test_that_order_matters(self):
- wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
+ wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall2, related_element=wall1)
+ ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall2, related_element=wall1)
assert len([e for e in self.file]) == total_elements
diff --git a/src/ifcopenshell-python/test/api/geometry/test_edit_object_placement.py b/src/ifcopenshell-python/test/api/geometry/test_edit_object_placement.py
index ff7a9c587a..85b32435a3 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_edit_object_placement.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_edit_object_placement.py
@@ -19,21 +19,27 @@
import numpy
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.void
+import ifcopenshell.api.root
+import ifcopenshell.api.unit
+import ifcopenshell.api.system
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
import ifcopenshell.guid
import ifcopenshell.util.placement
class TestEditObjectPlacement(test.bootstrap.IFC4):
def test_attemping_to_edit_the_placement_of_an_invalid_element(self):
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- result = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=project)
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ result = ifcopenshell.api.geometry.edit_object_placement(self.file, product=project)
assert result is None
def test_setting_an_object_placement(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -42,15 +48,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
def test_setting_an_object_placement_using_si_units(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -67,15 +71,15 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element, matrix=matrix, is_si=True)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix, is_si=True)
assert numpy.array_equal(
ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix_millimeters
)
def test_changing_an_object_placement(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -92,23 +96,19 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
created_element_ids = [e.id() for e in self.file.traverse(element.ObjectPlacement)]
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
for element_id in created_element_ids:
with pytest.raises(RuntimeError):
self.file.by_id(element_id)
def test_changing_an_object_placement_used_by_other_products(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -125,21 +125,17 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
element2.ObjectPlacement = element.ObjectPlacement
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
assert element.ObjectPlacement != element2.ObjectPlacement
def test_changing_an_object_placement_partially_used_by_other_products(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -156,24 +152,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
element2.ObjectPlacement = self.file.createIfcLocalPlacement(
RelativePlacement=element.ObjectPlacement.RelativePlacement
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element2.ObjectPlacement), matrix1)
def test_changing_an_object_placement_shared_by_its_parent(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -190,22 +182,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
- )
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
subelement.ObjectPlacement = element.ObjectPlacement
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=matrix2.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=matrix2.copy(), is_si=False
)
assert subelement.ObjectPlacement.PlacementRelTo != subelement.ObjectPlacement
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), matrix2)
assert element.ObjectPlacement != subelement.ObjectPlacement
def test_changing_placements_relative_to_a_spatial_container(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -222,22 +212,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_relative_to_an_aggregate(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -254,22 +242,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_relative_to_a_nest_parent(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ subelement = ifcopenshell.api.system.add_port(self.file, element=element)
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -286,23 +272,21 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_relative_to_a_voided_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- site = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=site)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ site = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=site)
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -319,26 +303,24 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("void.add_opening", self.file, opening=subelement, element=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.void.add_opening(self.file, opening=subelement, element=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_relative_to_an_opening(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- site = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[wall], relating_structure=site)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=site)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ site = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[wall], relating_structure=site)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=site)
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -355,19 +337,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("void.add_opening", self.file, opening=element, element=wall)
- ifcopenshell.api.run("void.add_filling", self.file, element=subelement, opening=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=site, matrix=numpy.eye(4), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=wall, matrix=numpy.eye(4), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.void.add_opening(self.file, opening=element, element=wall)
+ ifcopenshell.api.void.add_filling(self.file, element=subelement, opening=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=site, matrix=numpy.eye(4), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=wall, matrix=numpy.eye(4), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
@@ -377,10 +353,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_relative_to_a_projected_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectionElement")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectionElement")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -405,21 +381,19 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
"RelatedFeatureElement": subelement,
},
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_without_affecting_children(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -436,25 +410,23 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), submatrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_with_affecting_children(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -479,15 +451,12 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=element,
matrix=submatrix.copy(),
@@ -501,10 +470,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_with_children_using_non_si_units(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1000.0),
@@ -529,25 +498,21 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix_si.copy(), is_si=True
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix_si.copy(), is_si=True)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
def test_changing_placements_always_affecting_child_ports_as_a_special_case(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ subelement = ifcopenshell.api.system.add_port(self.file, element=element)
matrix = numpy.eye(4)
matrix[:3, 3] = (1, 1, 1)
@@ -558,14 +523,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
shifted_submatrix = numpy.eye(4)
shifted_submatrix[:3, 3] = (1, 3, 5)
- previous_placement_id = ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
+ previous_placement_id = ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element, matrix=matrix.copy(), is_si=False
).id()
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=element,
matrix=submatrix.copy(),
@@ -582,10 +546,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
self.file.by_id(previous_placement_id)
def test_changing_placements_always_affecting_child_features_as_a_special_case(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
matrix = numpy.eye(4)
matrix[:3, 3] = (1, 1, 1)
@@ -596,15 +560,14 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
shifted_submatrix = numpy.eye(4)
shifted_submatrix[:3, 3] = (1, 3, 5)
- ifcopenshell.api.run("void.add_opening", self.file, opening=subelement, element=element)
- previous_placement_id = ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
+ ifcopenshell.api.void.add_opening(self.file, opening=subelement, element=element)
+ previous_placement_id = ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element, matrix=matrix.copy(), is_si=False
).id()
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=element,
matrix=submatrix.copy(),
@@ -625,28 +588,27 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
(m := numpy.eye(4))[:3, 3] = translation
return m
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- storey = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[storey], relating_object=building)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[wall], relating_structure=storey)
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[wall], relating_structure=storey)
matrix = np_matrix_translation((1, 1, 1))
submatrix = np_matrix_translation((1, 2, 3))
- building_placement_id = ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=building, matrix=matrix.copy(), is_si=False
+ building_placement_id = ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=building, matrix=matrix.copy(), is_si=False
).id()
- storey_placement_id = ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=storey, matrix=matrix.copy(), is_si=False
+ storey_placement_id = ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=storey, matrix=matrix.copy(), is_si=False
).id()
- wall_placement_id = ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=wall, matrix=matrix.copy(), is_si=False
+ wall_placement_id = ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=wall, matrix=matrix.copy(), is_si=False
).id()
- ifcopenshell.api.run(
- "geometry.edit_object_placement",
+ ifcopenshell.api.geometry.edit_object_placement(
self.file,
product=building,
matrix=submatrix.copy(),
@@ -664,10 +626,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
class TestEditObjectPlacementIFC2X3(test.bootstrap.IFC2X3, TestEditObjectPlacement):
def test_changing_placements_relative_to_a_distribution_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ subelement = ifcopenshell.api.system.add_port(self.file, element=element)
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -684,11 +646,9 @@ class TestEditObjectPlacementIFC2X3(test.bootstrap.IFC2X3, TestEditObjectPlaceme
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
- )
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
diff --git a/src/ifcopenshell-python/test/api/geometry/test_remove_representation.py b/src/ifcopenshell-python/test/api/geometry/test_remove_representation.py
index a1b52e8eb1..4363cc8ac8 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_remove_representation.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_remove_representation.py
@@ -17,19 +17,19 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.geometry
class TestRemoveRepresentation(test.bootstrap.IFC4):
def test_removing_a_single_unused_shape_representation(self):
representation = self.file.createIfcShapeRepresentation()
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
def test_not_removing_a_shape_representation_in_use(self):
representation = self.file.createIfcShapeRepresentation()
self.file.createIfcProductRepresentation(Representations=[representation])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
def test_removing_a_mapped_representation_fully(self):
@@ -44,7 +44,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
],
)
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
def test_removing_only_the_representation_mapping_if_the_map_has_other_users(self):
@@ -57,7 +57,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
Items=[self.file.createIfcMappedItem(MappingTarget=representation_map)],
)
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
assert self.file.by_type("IfcShapeRepresentation")[0].RepresentationType != "MappedRepresentation"
assert len(self.file.by_type("IfcRepresentationMap")) == 1
@@ -67,7 +67,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
representation = self.file.createIfcShapeRepresentation(Items=[item])
surface_style = self.file.createIfcSurfaceStyle()
styled_item = self.file.createIfcStyledItem(Item=item, Styles=[surface_style])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcStyledItem")) == 0
assert len(self.file.by_type("IfcSurfaceStyle")) == 1
@@ -76,13 +76,13 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
representation = self.file.createIfcShapeRepresentation(Items=[item])
styled_item = self.file.createIfcStyledItem(Item=item)
representation2 = self.file.createIfcShapeRepresentation(Items=[item])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcStyledItem")) == 1
def test_purging_representation_presentation_layers(self):
representation = self.file.createIfcShapeRepresentation()
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
@@ -90,7 +90,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
representation = self.file.createIfcShapeRepresentation()
representation2 = self.file.createIfcShapeRepresentation()
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation, representation2])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
@@ -98,7 +98,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
item = self.file.createIfcExtrudedAreaSolid()
representation = self.file.createIfcShapeRepresentation(Items=[item])
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 0
@@ -107,21 +107,21 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
representation = self.file.createIfcShapeRepresentation(Items=[item])
representation2 = self.file.createIfcShapeRepresentation(Items=[item2])
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item, item2])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 1
def test_not_purging_geometric_representation_contexts(self):
context = self.file.createIfcGeometricRepresentationSubContext()
representation = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
def test_purging_colour_map(self):
item = self.file.createIfcTriangulatedFaceSet()
representation = self.file.createIfcShapeRepresentation(Items=[item])
colour = self.file.createIfcIndexedColourMap(Colours=self.file.createIfcColourRgbList(), MappedTo=item)
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcIndexedColourMap")) == 0
assert len(self.file.by_type("IfcColourRgbList")) == 0
@@ -132,7 +132,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
texture = self.file.createIfcIndexedTriangleTextureMap(
TexCoords=self.file.createIfcTextureVertexList(), MappedTo=item, Maps=[image]
)
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcIndexedTriangleTextureMap")) == 0
assert len(self.file.by_type("IfcTextureVertexList")) == 0
assert len(self.file.by_type("IfcImageTexture")) == 0
@@ -145,7 +145,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
TexCoords=self.file.createIfcTextureVertexList(), MappedTo=item, Maps=[image]
)
texture2 = self.file.createIfcIndexedTriangleTextureMap(Maps=[image])
- ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
+ ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
assert len(self.file.by_type("IfcIndexedTriangleTextureMap")) == 1
assert len(self.file.by_type("IfcTextureVertexList")) == 0
assert len(self.file.by_type("IfcImageTexture")) == 1
diff --git a/src/ifcopenshell-python/test/api/geometry/test_unassign_representation.py b/src/ifcopenshell-python/test/api/geometry/test_unassign_representation.py
index 6938d54d72..d43df03c6f 100644
--- a/src/ifcopenshell-python/test/api/geometry/test_unassign_representation.py
+++ b/src/ifcopenshell-python/test/api/geometry/test_unassign_representation.py
@@ -16,10 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.geometry
import ifcopenshell.util.placement
@@ -30,10 +28,10 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
wall = self.file.createIfcWall(
Representation=self.file.createIfcProductDefinitionShape(Representations=[representation, representation2])
)
- ifcopenshell.api.run("geometry.unassign_representation", self.file, product=wall, representation=representation)
+ ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation)
assert representation not in wall.Representation.Representations
- ifcopenshell.api.run(
- "geometry.unassign_representation", self.file, product=wall, representation=representation2
+ ifcopenshell.api.geometry.unassign_representation(
+ self.file, product=wall, representation=representation2
)
assert not wall.Representation
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
@@ -44,8 +42,8 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
origin = self.file.createIfcAxis2Placement3D()
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
- ifcopenshell.api.run(
- "geometry.unassign_representation", self.file, product=walltype, representation=representation
+ ifcopenshell.api.geometry.unassign_representation(
+ self.file, product=walltype, representation=representation
)
assert not walltype.RepresentationMaps
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
@@ -61,8 +59,8 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
rep = self.file.createIfcShapeRepresentation(Items=[mapped_item])
prodrep = self.file.createIfcProductDefinitionShape(Representations=[rep])
wall = self.file.createIfcWall(Representation=prodrep)
- ifcopenshell.api.run(
- "geometry.unassign_representation", self.file, product=walltype, representation=representation
+ ifcopenshell.api.geometry.unassign_representation(
+ self.file, product=walltype, representation=representation
)
assert not walltype.RepresentationMaps
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
diff --git a/src/ifcopenshell-python/test/api/grid/test_create_grid_axis.py b/src/ifcopenshell-python/test/api/grid/test_create_grid_axis.py
index ef151cc2ee..518f6308d2 100644
--- a/src/ifcopenshell-python/test/api/grid/test_create_grid_axis.py
+++ b/src/ifcopenshell-python/test/api/grid/test_create_grid_axis.py
@@ -17,20 +17,20 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.grid
class TestCreateGridAxis(test.bootstrap.IFC4):
def test_run(self):
grid = self.file.createIfcGrid()
- axis = ifcopenshell.api.run(
- "grid.create_grid_axis", self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
+ axis = ifcopenshell.api.grid.create_grid_axis(
+ self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
)
assert axis.AxisTag == "axis_tag"
assert axis.SameSense is True
assert grid.UAxes == (axis,)
- axis2 = ifcopenshell.api.run(
- "grid.create_grid_axis", self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
+ axis2 = ifcopenshell.api.grid.create_grid_axis(
+ self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
)
assert grid.UAxes == (axis, axis2)
diff --git a/src/ifcopenshell-python/test/api/group/test_add_group.py b/src/ifcopenshell-python/test/api/group/test_add_group.py
index 49e5379ade..0c8af993ab 100644
--- a/src/ifcopenshell-python/test/api/group/test_add_group.py
+++ b/src/ifcopenshell-python/test/api/group/test_add_group.py
@@ -17,18 +17,18 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.group
import ifcopenshell.util.element
class TestAddGroup(test.bootstrap.IFC4):
def test_add_group_no_arguments(self):
- group = ifcopenshell.api.run("group.add_group", self.file)
+ group = ifcopenshell.api.group.add_group(self.file)
assert group.Name == "Unnamed"
assert group.Description == None
def test_add_group(self):
- group = ifcopenshell.api.run("group.add_group", self.file, name="Name", description="Description")
+ group = ifcopenshell.api.group.add_group(self.file, name="Name", description="Description")
assert group.Name == "Name"
assert group.Description == "Description"
diff --git a/src/ifcopenshell-python/test/api/group/test_assign_group.py b/src/ifcopenshell-python/test/api/group/test_assign_group.py
index 434dab2b32..85b2711e27 100644
--- a/src/ifcopenshell-python/test/api/group/test_assign_group.py
+++ b/src/ifcopenshell-python/test/api/group/test_assign_group.py
@@ -17,27 +17,28 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.group
import ifcopenshell.util.element
class TestAssignGroup(test.bootstrap.IFC4):
def test_assign_group_for_multiple_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file)
# assign group for multiple elements
- ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2], group=group)
+ ifcopenshell.api.group.assign_group(self.file, products=[element, element2], group=group)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(self.file.by_type("IfcWall"))
def test_reuse_existing_relationship(self):
self.test_assign_group_for_multiple_elements()
rel = self.file.by_type("IfcRelAssignsToGroup")[0]
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
group = self.file.by_type("IfcGroup")[0]
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(self.file.by_type("IfcWall"))
diff --git a/src/ifcopenshell-python/test/api/group/test_remove_group.py b/src/ifcopenshell-python/test/api/group/test_remove_group.py
index 5936a40058..28e59493c5 100644
--- a/src/ifcopenshell-python/test/api/group/test_remove_group.py
+++ b/src/ifcopenshell-python/test/api/group/test_remove_group.py
@@ -17,27 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.group
class TestRemoveGroup(test.bootstrap.IFC4):
def test_removing_a_group(self):
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.remove_group", self.file, group=group)
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.remove_group(self.file, group=group)
assert len(self.file.by_type("IfcGroup")) == 0
def test_removing_orphaned_group_relationships(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
- ifcopenshell.api.run("group.remove_group", self.file, group=group)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
+ ifcopenshell.api.group.remove_group(self.file, group=group)
assert not self.file.by_type("IfcRelAssignsToGroup")
def test_removing_orphaned_property_relationships(self):
- group = ifcopenshell.api.run("group.add_group", self.file)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=group, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
- ifcopenshell.api.run("group.remove_group", self.file, group=group)
+ group = ifcopenshell.api.group.add_group(self.file)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=group, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
+ ifcopenshell.api.group.remove_group(self.file, group=group)
assert not self.file.by_type("IfcRelDefinesByProperties")
assert not self.file.by_type("IfcPropertySet")
assert not self.file.by_type("IfcPropertySingleValue")
diff --git a/src/ifcopenshell-python/test/api/group/test_unassign_group.py b/src/ifcopenshell-python/test/api/group/test_unassign_group.py
index 86029ab6d9..c40b4affcb 100644
--- a/src/ifcopenshell-python/test/api/group/test_unassign_group.py
+++ b/src/ifcopenshell-python/test/api/group/test_unassign_group.py
@@ -17,17 +17,18 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.group
class TestAssignGroup(test.bootstrap.IFC4):
def test_group_unassignment(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2, element3], group=group)
- ifcopenshell.api.run("group.unassign_group", self.file, products=[element2, element3], group=group)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.assign_group(self.file, products=[element, element2, element3], group=group)
+ ifcopenshell.api.group.unassign_group(self.file, products=[element2, element3], group=group)
assert len(rels := self.file.by_type("IfcRelAssignsToGroup")) == 1
rel = rels[0]
@@ -35,11 +36,11 @@ class TestAssignGroup(test.bootstrap.IFC4):
assert rel.RelatedObjects == (element,)
def test_remove_relationship_unassigning_last_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2], group=group)
- ifcopenshell.api.run("group.unassign_group", self.file, products=[element, element2], group=group)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.assign_group(self.file, products=[element, element2], group=group)
+ ifcopenshell.api.group.unassign_group(self.file, products=[element, element2], group=group)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 0
diff --git a/src/ifcopenshell-python/test/api/group/test_update_group_products.py b/src/ifcopenshell-python/test/api/group/test_update_group_products.py
index bd08bab0a7..56d685de9a 100644
--- a/src/ifcopenshell-python/test/api/group/test_update_group_products.py
+++ b/src/ifcopenshell-python/test/api/group/test_update_group_products.py
@@ -17,22 +17,23 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.group
import ifcopenshell.util.element
class TestUpdateGroupProductsIFC2X3(test.bootstrap.IFC2X3):
def test_update_group_without_products(self):
- elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.update_group_products", self.file, products=elements, group=group)
+ elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.update_group_products(self.file, products=elements, group=group)
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements)
def test_update_group_products(self):
- elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.assign_group", self.file, products=elements[:2], group=group)
- ifcopenshell.api.run("group.update_group_products", self.file, products=elements[2:], group=group)
+ elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.assign_group(self.file, products=elements[:2], group=group)
+ ifcopenshell.api.group.update_group_products(self.file, products=elements[2:], group=group)
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements[2:])
assert ifcopenshell.util.element.get_groups(elements[0]) == []
assert ifcopenshell.util.element.get_groups(elements[1]) == []
@@ -41,13 +42,13 @@ class TestUpdateGroupProductsIFC2X3(test.bootstrap.IFC2X3):
class TestUpdateGroupProductsIFC4(test.bootstrap.IFC4, TestUpdateGroupProductsIFC2X3):
def test_update_group_products(self):
# in ifc4 IfcGroup can have multiple rels
- elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
- group = ifcopenshell.api.run("group.add_group", self.file)
+ elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
+ group = ifcopenshell.api.group.add_group(self.file)
self.file.create_entity("IfcRelAssignsToGroup", RelatingGroup=group, RelatedObjects=elements[:1])
self.file.create_entity("IfcRelAssignsToGroup", RelatingGroup=group, RelatedObjects=elements[1:2])
- ifcopenshell.api.run("group.update_group_products", self.file, products=elements[2:], group=group)
+ ifcopenshell.api.group.update_group_products(self.file, products=elements[2:], group=group)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements[2:])
assert ifcopenshell.util.element.get_groups(elements[0]) == []
diff --git a/src/ifcopenshell-python/test/api/layer/test_add_layer.py b/src/ifcopenshell-python/test/api/layer/test_add_layer.py
index 8889674075..97635ccb63 100644
--- a/src/ifcopenshell-python/test/api/layer/test_add_layer.py
+++ b/src/ifcopenshell-python/test/api/layer/test_add_layer.py
@@ -17,16 +17,16 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.layer
class TestAddLayer(test.bootstrap.IFC4):
def test_add_layer_no_arguments(self):
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ layer = ifcopenshell.api.layer.add_layer(self.file)
assert layer.Name == "Unnamed"
def test_assign_additional_items(self):
- layer = ifcopenshell.api.run("layer.add_layer", self.file, name="Name")
+ layer = ifcopenshell.api.layer.add_layer(self.file, name="Name")
assert layer.Name == "Name"
diff --git a/src/ifcopenshell-python/test/api/layer/test_assign_layer.py b/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
index 2e05162aad..f2b0e831d9 100644
--- a/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
+++ b/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.layer
class TestAssignLayer(test.bootstrap.IFC4):
@@ -25,7 +25,7 @@ class TestAssignLayer(test.bootstrap.IFC4):
items = [self.file.createIfcExtrudedAreaSolid() for i in range(2)]
layer = self.file.createIfcPresentationLayerAssignment()
- ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
assert len(layer.AssignedItems) == 2
assert set(layer.AssignedItems) == set(items)
@@ -33,8 +33,8 @@ class TestAssignLayer(test.bootstrap.IFC4):
items = [self.file.createIfcExtrudedAreaSolid() for i in range(4)]
layer = self.file.createIfcPresentationLayerAssignment()
- ifcopenshell.api.run("layer.assign_layer", self.file, items=items[:2], layer=layer)
- ifcopenshell.api.run("layer.assign_layer", self.file, items=items[2:], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=items[:2], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=items[2:], layer=layer)
assert len(layer.AssignedItems) == 4
assert set(layer.AssignedItems) == set(items)
diff --git a/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py b/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
index 7332c67715..018c9125f5 100644
--- a/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
+++ b/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.layer
class TestUnassignLayer(test.bootstrap.IFC4):
@@ -25,8 +25,8 @@ class TestUnassignLayer(test.bootstrap.IFC4):
items = [self.file.createIfcExtrudedAreaSolid() for i in range(3)]
layer = self.file.createIfcPresentationLayerAssignment()
- ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
- ifcopenshell.api.run("layer.unassign_layer", self.file, items=items[2:], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
+ ifcopenshell.api.layer.unassign_layer(self.file, items=items[2:], layer=layer)
assert len(layer.AssignedItems) == 2
assert set(layer.AssignedItems) == set(items[:2])
@@ -34,8 +34,8 @@ class TestUnassignLayer(test.bootstrap.IFC4):
items = [self.file.createIfcExtrudedAreaSolid() for i in range(3)]
layer = self.file.createIfcPresentationLayerAssignment()
- ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
- ifcopenshell.api.run("layer.unassign_layer", self.file, items=items, layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
+ ifcopenshell.api.layer.unassign_layer(self.file, items=items, layer=layer)
assert not self.file.by_type("IfcPresentationLayerAssignment")
diff --git a/src/ifcopenshell-python/test/api/library/test_add_library.py b/src/ifcopenshell-python/test/api/library/test_add_library.py
index f964b180ac..e2cd440028 100644
--- a/src/ifcopenshell-python/test/api/library/test_add_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_add_library.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestAddLibrary(test.bootstrap.IFC4):
def test_adding_a_library(self):
- library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
+ library = ifcopenshell.api.library.add_library(self.file, name="Name")
assert library.is_a("IfcLibraryInformation")
assert library.Name == "Name"
diff --git a/src/ifcopenshell-python/test/api/library/test_add_reference.py b/src/ifcopenshell-python/test/api/library/test_add_reference.py
index c0791e1855..95f23d495f 100644
--- a/src/ifcopenshell-python/test/api/library/test_add_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_add_reference.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestAddReference(test.bootstrap.IFC4):
def test_adding_a_reference(self):
- library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
- reference = ifcopenshell.api.run("library.add_reference", self.file, library=library)
+ library = ifcopenshell.api.library.add_library(self.file, name="Name")
+ reference = ifcopenshell.api.library.add_reference(self.file, library=library)
assert reference.is_a("IfcLibraryReference")
ifc2x3 = self.file.schema == "IFC2X3"
if ifc2x3:
diff --git a/src/ifcopenshell-python/test/api/library/test_assign_reference.py b/src/ifcopenshell-python/test/api/library/test_assign_reference.py
index 5d00d20972..988d4c2265 100644
--- a/src/ifcopenshell-python/test/api/library/test_assign_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_assign_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestAssignReference(test.bootstrap.IFC4):
@@ -26,17 +26,17 @@ class TestAssignReference(test.bootstrap.IFC4):
product = self.file.createIfcWall()
product2 = self.file.createIfcWall()
product3 = self.file.createIfcWall()
- ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
assert rel.RelatedObjects == (product,)
- ifcopenshell.api.run("library.assign_reference", self.file, products=[product2, product3], reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=[product2, product3], reference=reference)
assert set(rel.RelatedObjects) == set((product, product2, product3))
def test_not_assigning_twice(self):
reference = self.file.createIfcLibraryReference()
product = self.file.createIfcWall()
- ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
- ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
assert rel.RelatedObjects == (product,)
diff --git a/src/ifcopenshell-python/test/api/library/test_edit_library.py b/src/ifcopenshell-python/test/api/library/test_edit_library.py
index 7d6d570666..26f46d3016 100644
--- a/src/ifcopenshell-python/test/api/library/test_edit_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_edit_library.py
@@ -18,7 +18,7 @@
import test.bootstrap
import datetime
-import ifcopenshell.api
+import ifcopenshell.api.library
import ifcopenshell.util.date
@@ -35,8 +35,7 @@ class TestEditLibrary(test.bootstrap.IFC4):
attributes["Location"] = "Location"
attributes["Description"] = "Description"
- ifcopenshell.api.run(
- "library.edit_library",
+ ifcopenshell.api.library.edit_library(
self.file,
library=library,
attributes=attributes,
diff --git a/src/ifcopenshell-python/test/api/library/test_edit_reference.py b/src/ifcopenshell-python/test/api/library/test_edit_reference.py
index 338b9f4f74..b979a56357 100644
--- a/src/ifcopenshell-python/test/api/library/test_edit_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_edit_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestEditReference(test.bootstrap.IFC4):
@@ -31,8 +31,7 @@ class TestEditReference(test.bootstrap.IFC4):
if self.file.schema != "IFC2X3":
attributes["Description"] = "Description"
attributes["Language"] = "Language"
- ifcopenshell.api.run(
- "library.edit_reference",
+ ifcopenshell.api.library.edit_reference(
self.file,
reference=reference,
attributes=attributes,
diff --git a/src/ifcopenshell-python/test/api/library/test_remove_library.py b/src/ifcopenshell-python/test/api/library/test_remove_library.py
index a4743deb99..7376d4a288 100644
--- a/src/ifcopenshell-python/test/api/library/test_remove_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_remove_library.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestRemoveLibrary(test.bootstrap.IFC4):
def test_removing_a_library(self):
library = self.file.createIfcLibraryInformation()
- ifcopenshell.api.run("library.remove_library", self.file, library=library)
+ ifcopenshell.api.library.remove_library(self.file, library=library)
assert len(self.file.by_type("IfcLibraryInformation")) == 0
def test_removing_a_library_and_all_references(self):
@@ -38,7 +38,7 @@ class TestRemoveLibrary(test.bootstrap.IFC4):
self.file.createIfcRelAssociatesLibrary(GlobalId="foo", RelatingLibrary=library)
self.file.createIfcRelAssociatesLibrary(GlobalId="bar", RelatingLibrary=reference1)
- ifcopenshell.api.run("library.remove_library", self.file, library=library)
+ ifcopenshell.api.library.remove_library(self.file, library=library)
assert len(self.file.by_type("IfcLibraryReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
diff --git a/src/ifcopenshell-python/test/api/library/test_remove_reference.py b/src/ifcopenshell-python/test/api/library/test_remove_reference.py
index fdeca97fb5..f6f6d90588 100644
--- a/src/ifcopenshell-python/test/api/library/test_remove_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_remove_reference.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
class TestRemoveReference(test.bootstrap.IFC4):
def test_removing_a_reference(self):
reference = self.file.createIfcLibraryReference()
product = self.file.createIfcWall()
- ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
- ifcopenshell.api.run("library.remove_reference", self.file, reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
+ ifcopenshell.api.library.remove_reference(self.file, reference=reference)
assert len(self.file.by_type("IfcLibraryReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
diff --git a/src/ifcopenshell-python/test/api/library/test_unassign_reference.py b/src/ifcopenshell-python/test/api/library/test_unassign_reference.py
index 8962bb686a..480ddb6eec 100644
--- a/src/ifcopenshell-python/test/api/library/test_unassign_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_unassign_reference.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.library
import ifcopenshell.util.element
@@ -25,11 +25,11 @@ class TestUnassignReference(test.bootstrap.IFC4):
def test_unassigning_a_reference(self):
reference = self.file.createIfcLibraryReference()
products = [self.file.createIfcWall() for i in range(3)]
- ifcopenshell.api.run("library.assign_reference", self.file, products=products, reference=reference)
- ifcopenshell.api.run("library.unassign_reference", self.file, products=products[:1], reference=reference)
+ ifcopenshell.api.library.assign_reference(self.file, products=products, reference=reference)
+ ifcopenshell.api.library.unassign_reference(self.file, products=products[:1], reference=reference)
assert ifcopenshell.util.element.get_referenced_elements(reference) == set(products[1:])
- ifcopenshell.api.run("library.unassign_reference", self.file, products=products[1:], reference=reference)
+ ifcopenshell.api.library.unassign_reference(self.file, products=products[1:], reference=reference)
assert ifcopenshell.util.element.get_referenced_elements(reference) == set()
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
diff --git a/src/ifcopenshell-python/test/api/material/test_add_material_set.py b/src/ifcopenshell-python/test/api/material/test_add_material_set.py
index ec711d8a0e..758c40b824 100644
--- a/src/ifcopenshell-python/test/api/material/test_add_material_set.py
+++ b/src/ifcopenshell-python/test/api/material/test_add_material_set.py
@@ -17,28 +17,28 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.material
class TestAddMaterialSetIFC2X3(test.bootstrap.IFC2X3):
def test_add_layer_set(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
assert material.LayerSetName == "Unnamed"
assert material.is_a("IfcMaterialLayerSet")
def test_add_list(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
assert material.is_a("IfcMaterialList")
class TestAddMaterialSetIFC4(test.bootstrap.IFC4, TestAddMaterialSetIFC2X3):
# entities added in IFC4
def test_add_profile_set(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
assert material.Name == "Unnamed"
assert material.is_a("IfcMaterialProfileSet")
def test_add_constituent_set(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialConstituentSet")
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
assert material.Name == "Unnamed"
assert material.is_a("IfcMaterialConstituentSet")
diff --git a/src/ifcopenshell-python/test/api/material/test_assign_material.py b/src/ifcopenshell-python/test/api/material/test_assign_material.py
index 4577e7eed5..822ac57803 100644
--- a/src/ifcopenshell-python/test/api/material/test_assign_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_assign_material.py
@@ -16,48 +16,45 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.material
import ifcopenshell.util.element
class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
def test_assign_element_single_material(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterial", material=material
)
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert ifcopenshell.util.element.get_material(element1) == material
assert ifcopenshell.util.element.get_material(element2) == material
def test_raise_exception_creating_ifc_material_without(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterial", material=None
- )
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterial", material=None)
assert ifcopenshell.util.element.get_material(element)
def test_assign_type_single_material(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterial", material=material
)
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert ifcopenshell.util.element.get_material(element1) == material
assert ifcopenshell.util.element.get_material(element2) == material
def test_assign_type_material_layer_set(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSet"
- )
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element1, element2], type="IfcMaterialLayerSet")
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
material_set = ifcopenshell.util.element.get_material(element1)
assert material_set.is_a("IfcMaterialLayerSet")
@@ -65,15 +62,13 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert ifcopenshell.util.element.get_material(element2) == material_set
def test_assign_type_material_layer_set_and_element_layer_set_usage(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
- )
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
)
material_set = ifcopenshell.util.element.get_material(element_type)
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
@@ -82,22 +77,18 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
def test_assign_type_material_layer_set_and_element_layer_set_usage_is_different_for_different_types(self):
- element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type1], type="IfcMaterialLayerSet"
- )
+ element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type1)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type1], type="IfcMaterialLayerSet")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type2], type="IfcMaterialLayerSet"
- )
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type2)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type2], type="IfcMaterialLayerSet")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
)
material_set1 = ifcopenshell.util.element.get_material(element_type1)
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
@@ -111,10 +102,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert material_usage2 != material_usage1
def test_assign_element_layer_set_usage_is_different_for_different_layer_set_directions(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
)
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
@@ -133,11 +124,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert material_usage1 != material_usage2
def test_assign_element_material_list(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material",
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
self.file,
products=[element1, element2],
type="IfcMaterialList",
@@ -152,10 +142,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
def test_assign_type_material_profile_set(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSet"
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialProfileSet"
)
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
material_set = ifcopenshell.util.element.get_material(element1)
@@ -164,17 +154,13 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
assert ifcopenshell.util.element.get_material(element2) == material_set
def test_assign_type_material_profile_set_and_element_profile_set_usage(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
- )
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet"
- )
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialProfileSet")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
)
material_set = element_type.HasAssociations[0].RelatingMaterial
material_usage1 = element1.HasAssociations[0].RelatingMaterial
@@ -183,22 +169,18 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
def test_assign_type_material_profile_set_and_element_profile_set_usage_is_different_for_different_types(self):
- element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type1], type="IfcMaterialProfileSet"
- )
+ element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type1)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type1], type="IfcMaterialProfileSet")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type2], type="IfcMaterialProfileSet"
- )
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type2)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type2], type="IfcMaterialProfileSet")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
)
material_set1 = ifcopenshell.util.element.get_material(element_type1)
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
@@ -212,10 +194,10 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
assert material_usage2 != material_usage1
def test_assign_type_material_constituent_set(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
)
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
material_set = ifcopenshell.util.element.get_material(element1)
diff --git a/src/ifcopenshell-python/test/api/material/test_copy_material.py b/src/ifcopenshell-python/test/api/material/test_copy_material.py
index 3f88d6732d..2faa210e6c 100644
--- a/src/ifcopenshell-python/test/api/material/test_copy_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_copy_material.py
@@ -17,22 +17,26 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.style
+import ifcopenshell.api.context
+import ifcopenshell.api.material
import ifcopenshell.util.element
class TestCopyMaterial(test.bootstrap.IFC4):
def test_copy_a_single_material(self):
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ new = ifcopenshell.api.material.copy_material(self.file, material=material)
assert new.Name == "CON01"
assert len(self.file.by_type("IfcMaterial")) == 2
def test_assignments_are_not_copied(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material)
assert ifcopenshell.util.element.get_elements_by_material(self.file, material)
assert not ifcopenshell.util.element.get_elements_by_material(self.file, new)
@@ -42,10 +46,10 @@ class TestCopyMaterial(test.bootstrap.IFC4):
return material.HasProperties
return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
+ new = ifcopenshell.api.material.copy_material(self.file, material=material)
assert new.Name == "CON01"
assert len(self.file.by_type("IfcMaterial")) == 2
assert len(self.file.by_type("IfcMaterialProperties")) == 2
@@ -60,12 +64,12 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert props_new.ExtendedProperties[0].NominalValue.wrappedValue == "bar"
def test_copy_a_material_with_a_style_representation(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- style = ifcopenshell.api.run("style.add_style", self.file)
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ style = ifcopenshell.api.style.add_style(self.file)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material)
assert new.Name == "CON01"
assert len(self.file.by_type("IfcPresentationStyle")) == 1
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 2
@@ -74,15 +78,13 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert new.HasRepresentation[0].Representations[0].ContextOfItems == context
def test_copy_a_material_constituent_set(self):
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, name="Foo", set_type="IfcMaterialConstituentSet"
- )
- item = ifcopenshell.api.run(
- "material.add_constituent", self.file, constituent_set=material_set, material=material
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, name="Foo", set_type="IfcMaterialConstituentSet"
)
+ item = ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
assert new != material_set
assert new.Name == "Foo"
assert new.MaterialConstituents[0] != item
@@ -92,13 +94,11 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcMaterial")) == 1
def test_copy_a_material_layer_set(self):
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, name="Foo", set_type="IfcMaterialLayerSet"
- )
- item = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ material_set = ifcopenshell.api.material.add_material_set(self.file, name="Foo", set_type="IfcMaterialLayerSet")
+ item = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
assert new != material_set
assert new.LayerSetName == "Foo"
assert new.MaterialLayers[0] != item
@@ -108,7 +108,7 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcMaterial")) == 1
def test_copy_a_material_profile_set(self):
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
profile = self.file.create_entity(
"IfcIShapeProfileDef",
ProfileName="HEA100",
@@ -119,14 +119,14 @@ class TestCopyMaterial(test.bootstrap.IFC4):
FlangeThickness=8,
FilletRadius=12,
)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, name="Foo", set_type="IfcMaterialProfileSet"
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, name="Foo", set_type="IfcMaterialProfileSet"
)
- item = ifcopenshell.api.run(
- "material.add_profile", self.file, profile_set=material_set, material=material, profile=profile
+ item = ifcopenshell.api.material.add_profile(
+ self.file, profile_set=material_set, material=material, profile=profile
)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
assert new != material_set
assert new.Name == "Foo"
assert new.MaterialProfiles[0] != item
@@ -138,11 +138,11 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcProfileDef")) == 1
def test_copy_a_material_list(self):
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
- ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
+ ifcopenshell.api.material.add_list_item(self.file, material_list=material_set, material=material)
- new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
+ new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
assert new != material_set
assert new.Materials[0] == material
assert len(self.file.by_type("IfcMaterialList")) == 2
diff --git a/src/ifcopenshell-python/test/api/material/test_remove_material.py b/src/ifcopenshell-python/test/api/material/test_remove_material.py
index e5690dcfd5..2498a6dbdd 100644
--- a/src/ifcopenshell-python/test/api/material/test_remove_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_remove_material.py
@@ -17,58 +17,62 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.style
+import ifcopenshell.api.context
+import ifcopenshell.api.material
class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
def test_removing_material(self):
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
def test_removing_material_with_associations(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
def test_removing_material_in_layer(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 0
def test_removing_material_in_list(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
- ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
+ ifcopenshell.api.material.add_list_item(self.file, material_list=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 0
def test_removing_a_material_with_a_style_definition(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- material = ifcopenshell.api.run("material.add_material", self.file)
- style = ifcopenshell.api.run("style.add_style", self.file)
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ material = ifcopenshell.api.material.add_material(self.file)
+ style = ifcopenshell.api.style.add_style(self.file)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 1
assert len(self.file.by_type("IfcStyledRepresentation")) == 1
assert len(self.file.by_type("IfcStyledItem")) == 1
assert len(self.file.by_type("IfcSurfaceStyle")) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 0
assert len(self.file.by_type("IfcStyledRepresentation")) == 0
@@ -81,11 +85,11 @@ class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
return material.HasProperties
return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
- material = ifcopenshell.api.run("material.add_material", self.file)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ material = ifcopenshell.api.material.add_material(self.file)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
assert get_material_props(material)
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterialProperties")) == 0
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
@@ -93,27 +97,27 @@ class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
class TestRemoveMaterialIFC4(test.bootstrap.IFC4, TestRemoveMaterialIFC2X3):
# IfcMaterialProfileSet added in IFC4
def test_removing_material_in_profile(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
- ifcopenshell.api.run("material.add_profile", self.file, profile_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
+ ifcopenshell.api.material.add_profile(self.file, profile_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 0
def test_removing_material_in_constituent(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, set_type="IfcMaterialConstituentSet"
)
- ifcopenshell.api.run("material.add_constituent", self.file, constituent_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ ifcopenshell.api.material.remove_material(self.file, material=material)
assert len(self.file.by_type("IfcMaterial")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents is None
diff --git a/src/ifcopenshell-python/test/api/material/test_remove_material_set.py b/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
index 0ec549d67a..b7f0b47dd5 100644
--- a/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
+++ b/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
@@ -17,28 +17,30 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.material
class TestRemoveMaterialSetIFC2X3(test.bootstrap.IFC2X3):
def test_removing_material_set(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.remove_material_set(self.file, material=material)
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
def test_removing_material_set_with_associations(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
- ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material)
+ ifcopenshell.api.material.remove_material_set(self.file, material=material)
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
def test_removing_a_material_set_with_set_items_but_preserving_materials(self):
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
- ifcopenshell.api.run("material.remove_material_set", self.file, material=material_set)
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
+ ifcopenshell.api.material.remove_material_set(self.file, material=material_set)
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
assert len(self.file.by_type("IfcMaterialLayer")) == 0
assert len(self.file.by_type("IfcMaterial")) == 1
@@ -47,10 +49,10 @@ class TestRemoveMaterialSetIFC2X3(test.bootstrap.IFC2X3):
class TestRemoveMaterialSetIFC4(test.bootstrap.IFC4, TestRemoveMaterialSetIFC2X3):
# IFC2X3 doesn't support adding a pset to IfcMaterialLayerSet
def test_removing_a_material_set_with_properties(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
assert material.HasProperties
- ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
+ ifcopenshell.api.material.remove_material_set(self.file, material=material)
assert len(self.file.by_type("IfcMaterialProperties")) == 0
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
diff --git a/src/ifcopenshell-python/test/api/material/test_unassign_material.py b/src/ifcopenshell-python/test/api/material/test_unassign_material.py
index f1f280f5ad..398661c7b0 100644
--- a/src/ifcopenshell-python/test/api/material/test_unassign_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_unassign_material.py
@@ -17,31 +17,33 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.material
import ifcopenshell.util.element
class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
def test_unassign_single_material(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterial", material=material
)
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
assert len(self.file.by_type("IfcWall")) == 2
assert len(self.file.by_type("IfcMaterial")) == 1
def test_unassign_single_material_with_multiple_elements(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterial", material=material
)
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element2])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element2])
assert element1.HasAssociations
assert not element2.HasAssociations
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
@@ -49,28 +51,24 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert len(self.file.by_type("IfcMaterial")) == 1
def test_unassign_material_layer_set_from_type(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSet"
- )
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element1, element2], type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
assert len(self.file.by_type("IfcWallType")) == 2
assert len(self.file.by_type("IfcMaterialLayerSet")) == 1
def test_unassign_material_layer_set_usage_from_element(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
- )
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert element_type.HasAssociations
assert len(self.file.by_type("IfcWallType")) == 1
@@ -79,20 +77,14 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert len(self.file.by_type("IfcMaterialLayerSetUsage")) == 0
def test_unassign_material_layer_set_usage_shouldnt_remove_other_usages_of_the_type(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
- )
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1], type="IfcMaterialLayerSetUsage"
- )
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element2], type="IfcMaterialLayerSetUsage"
- )
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1])
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.assign_material(self.file, products=[element1], type="IfcMaterialLayerSetUsage")
+ ifcopenshell.api.material.assign_material(self.file, products=[element2], type="IfcMaterialLayerSetUsage")
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 2
assert element_type.HasAssociations
assert len(self.file.by_type("IfcWallType")) == 1
@@ -101,20 +93,18 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert len(self.file.by_type("IfcMaterialLayerSetUsage")) == 1
def test_unassign_material_layer_set_usage_from_element_with_multiple_invalid_usages(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
- )
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
+ rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
# In some invalid IFCs from Revit, they reuse usages. Let's recreate this invalid scenario
rel.RelatedObjects = list(rel.RelatedObjects) + [element2]
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 2
for rel in self.file.by_type("IfcRelAssociatesMaterial"):
@@ -128,22 +118,21 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
assert ifcopenshell.util.element.get_material(element2, should_inherit=False).is_a("IfcMaterialLayerSetUsage")
def test_unassign_element_material_list(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material1 = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material",
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material1 = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
self.file,
products=[element1, element2],
type="IfcMaterialList",
material=material1,
)
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material3 = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element3], type="IfcMaterialList", material=material3
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material3 = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element3], type="IfcMaterialList", material=material3
)
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2, element3])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2, element3])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
assert len(self.file.by_type("IfcMaterialList")) == 2
assert len(self.file.by_type("IfcMaterial")) == 2
@@ -152,29 +141,25 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
class TestUnassignMaterialIFC4(test.bootstrap.IFC4, TestUnassignMaterialIFC2X3):
def test_unassign_material_profile_set_from_type(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element1], type="IfcMaterialProfileSet")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element2], type="IfcMaterialProfileSet")
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element1], type="IfcMaterialProfileSet")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element2], type="IfcMaterialProfileSet")
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
assert len(self.file.by_type("IfcWallType")) == 2
assert len(self.file.by_type("IfcMaterialProfileSet")) == 2
def test_unassign_material_profile_set_usage_from_element(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialProfileSet")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet"
- )
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
- )
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert element_type.HasAssociations
assert len(self.file.by_type("IfcWallType")) == 1
@@ -183,16 +168,14 @@ class TestUnassignMaterialIFC4(test.bootstrap.IFC4, TestUnassignMaterialIFC2X3):
assert len(self.file.by_type("IfcMaterialProfileSetUsage")) == 0
def test_unassign_material_constituent_set_from_type(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
)
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element3], type="IfcMaterialConstituentSet"
- )
- ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2, element3])
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element3], type="IfcMaterialConstituentSet")
+ ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2, element3])
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
assert len(self.file.by_type("IfcWallType")) == 3
assert len(self.file.by_type("IfcMaterialConstituentSet")) == 2
diff --git a/src/ifcopenshell-python/test/api/nest/test_assign_object.py b/src/ifcopenshell-python/test/api/nest/test_assign_object.py
index 181ff09fd7..73759a3bc7 100644
--- a/src/ifcopenshell-python/test/api/nest/test_assign_object.py
+++ b/src/ifcopenshell-python/test/api/nest/test_assign_object.py
@@ -18,68 +18,69 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.nest
+import ifcopenshell.api.root
import ifcopenshell.util.element
import ifcopenshell.util.placement
class TestAssignObject(test.bootstrap.IFC4):
def test_assigning_a_nesting(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- rel = ifcopenshell.api.run(
- "nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ rel = ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=[subelement1, subelement2], relating_object=element
)
assert ifcopenshell.util.element.get_nest(subelement1) == element
assert ifcopenshell.util.element.get_nest(subelement2) == element
assert rel.is_a("IfcRelNests")
def test_doing_nothing_if_the_nesting_is_already_assigned(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
assert len([e for e in self.file]) == total_elements
def test_that_old_nesting_relationships_are_updated_if_they_still_have_elements(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run(
- "nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element1
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=[subelement1, subelement2], relating_object=element1
)
rel = subelement1.Decomposes[0] if self.file.schema == "IFC2X3" else subelement1.Nests[0]
assert len(rel.RelatedObjects) == 2
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element2)
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element2)
assert len(rel.RelatedObjects) == 1
def test_that_old_nesting_relationships_are_purged_if_no_more_elements_are_nested(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element1)
rel_id = (subelement1.Decomposes[0] if self.file.schema == "IFC2X3" else subelement1.Nests[0]).id()
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element2)
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element2)
with pytest.raises(RuntimeError):
self.file.by_id(rel_id)
def test_maintain_assignment_order_in_related_objects(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask") for _ in range(5)]
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask") for _ in range(5)]
for i in range(5):
- ifcopenshell.api.run(
- "nest.assign_object", self.file, related_objects=subelements[: i + 1], relating_object=element
+ ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=subelements[: i + 1], relating_object=element
)
rel = self.file.by_type("IfcRelNests")[0]
assert rel.RelatedObjects == tuple(subelements[: i + 1])
# maintain the order in the affected relationships too
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run(
- "nest.assign_object", self.file, related_objects=subelements[2:3], relating_object=element2
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=subelements[2:3], relating_object=element2
)
assert rel.RelatedObjects == tuple(subelements[:2] + subelements[3:])
diff --git a/src/ifcopenshell-python/test/api/nest/test_unassign_object.py b/src/ifcopenshell-python/test/api/nest/test_unassign_object.py
index a23c452adf..9f3979b85d 100644
--- a/src/ifcopenshell-python/test/api/nest/test_unassign_object.py
+++ b/src/ifcopenshell-python/test/api/nest/test_unassign_object.py
@@ -16,43 +16,43 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.nest
+import ifcopenshell.api.root
import ifcopenshell.util.element
class TestUnassignObject(test.bootstrap.IFC4):
def test_unassigning_an_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run(
- "nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(
+ self.file, related_objects=[subelement1, subelement2], relating_object=element
)
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement1, subelement2])
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement1, subelement2])
assert ifcopenshell.util.element.get_nest(subelement1) is None
assert ifcopenshell.util.element.get_nest(subelement2) is None
def test_the_rel_is_kept_if_there_are_more_nested_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element)
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement2], relating_object=element)
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement1])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element)
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement2], relating_object=element)
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement1])
assert len(self.file.by_type("IfcRelNests")) == 1
def test_the_rel_is_purged_if_there_are_no_more_nested_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement])
assert len(self.file.by_type("IfcRelNests")) == 0
def test_maintain_assignment_order_in_related_objects(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask") for _ in range(5)]
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask") for _ in range(5)]
rel = self.file.create_entity("IfcRelNests", RelatingObject=element, RelatedObjects=subelements)
original_order = subelements.copy()
@@ -61,7 +61,7 @@ class TestUnassignObject(test.bootstrap.IFC4):
removed_elements = set()
for i in (0, 3, 2, 4):
subelement = subelements[i]
- ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement])
+ ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement])
removed_elements.add(subelement)
assert rel.RelatedObjects == tuple([o for o in original_order if o not in removed_elements])
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_actor.py b/src/ifcopenshell-python/test/api/owner/test_add_actor.py
index 82b43f9a96..2a4bf52cf7 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_actor.py
@@ -17,19 +17,19 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddActor(test.bootstrap.IFC4):
def test_adding_an_actor(self):
person = self.file.createIfcPerson()
- actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
+ actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
assert actor.is_a() == "IfcActor"
assert actor.TheActor == person
def test_adding_an_occupant(self):
person = self.file.createIfcPerson()
- actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
+ actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
assert actor.is_a() == "IfcOccupant"
assert actor.TheActor == person
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_address.py b/src/ifcopenshell-python/test/api/owner/test_add_address.py
index 31c18f6be4..16dc75f492 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_address.py
@@ -17,18 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddAddress(test.bootstrap.IFC4):
def test_adding_to_a_person(self):
person = self.file.createIfcPerson()
- postal = ifcopenshell.api.run(
- "owner.add_address", self.file, assigned_object=person, ifc_class="IfcPostalAddress"
- )
- telecom = ifcopenshell.api.run(
- "owner.add_address", self.file, assigned_object=person, ifc_class="IfcTelecomAddress"
- )
+ postal = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcPostalAddress")
+ telecom = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcTelecomAddress")
assert postal.is_a("IfcPostalAddress")
assert telecom.is_a("IfcTelecomAddress")
assert postal.Purpose == telecom.Purpose == "OFFICE"
@@ -37,11 +33,11 @@ class TestAddAddress(test.bootstrap.IFC4):
def test_adding_to_a_organisation(self):
organisation = self.file.createIfcOrganization()
- postal = ifcopenshell.api.run(
- "owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
+ postal = ifcopenshell.api.owner.add_address(
+ self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
)
- telecom = ifcopenshell.api.run(
- "owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
+ telecom = ifcopenshell.api.owner.add_address(
+ self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
)
assert postal.is_a("IfcPostalAddress")
assert telecom.is_a("IfcTelecomAddress")
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_application.py b/src/ifcopenshell-python/test/api/owner/test_add_application.py
index 182f4feea9..5a806160d5 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_application.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_application.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddApplication(test.bootstrap.IFC4):
def test_adding_the_ifcopenshell_application(self):
- application = ifcopenshell.api.run("owner.add_application", self.file)
+ application = ifcopenshell.api.owner.add_application(self.file)
developer = application.ApplicationDeveloper
assert application.Version == ifcopenshell.version
assert application.ApplicationFullName == "IfcOpenShell"
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_organisation.py b/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
index f7aad1c0a0..5f20a35129 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddOrganisation(test.bootstrap.IFC4):
def test_adding_an_organisation(self):
- org = ifcopenshell.api.run("owner.add_organisation", self.file, identification="Id", name="Name")
+ org = ifcopenshell.api.owner.add_organisation(self.file, identification="Id", name="Name")
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
assert org[0] == "Id"
assert org.Name == "Name"
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_person.py b/src/ifcopenshell-python/test/api/owner/test_add_person.py
index 6aed44c8db..9f1dc8e776 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_person.py
@@ -17,13 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddPerson(test.bootstrap.IFC4):
def test_adding_a_person(self):
- person = ifcopenshell.api.run(
- "owner.add_person",
+ person = ifcopenshell.api.owner.add_person(
self.file,
identification="Identification",
family_name="FamilyName",
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py b/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
index 079d162433..dd3518b167 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
def test_adding(self):
person = self.file.createIfcPerson()
organisation = self.file.createIfcOrganization()
- person_and_organisation = ifcopenshell.api.run(
- "owner.add_person_and_organisation", self.file, person=person, organisation=organisation
+ ifcopenshell.api.owner.add_person_and_organisation(
+ self.file, person=person, organisation=organisation
)
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_role.py b/src/ifcopenshell-python/test/api/owner/test_add_role.py
index 08351996b6..c98cba08e9 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_role.py
@@ -17,20 +17,20 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAddRole(test.bootstrap.IFC4):
def test_adding_a_role_to_a_person(self):
person = self.file.createIfcPerson()
- role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=person)
+ role = ifcopenshell.api.owner.add_role(self.file, assigned_object=person)
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert person.Roles == (role,)
def test_adding_a_role_to_an_organisation(self):
organisation = self.file.createIfcOrganization()
- role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=organisation)
+ role = ifcopenshell.api.owner.add_role(self.file, assigned_object=organisation)
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert organisation.Roles == (role,)
diff --git a/src/ifcopenshell-python/test/api/owner/test_assign_actor.py b/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
index bfd846ecfd..c4c6f84c24 100644
--- a/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestAssignActor(test.bootstrap.IFC4):
@@ -25,16 +25,16 @@ class TestAssignActor(test.bootstrap.IFC4):
wall = self.file.createIfcWall()
wall2 = self.file.createIfcWall()
actor = self.file.createIfcActor()
- ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
+ ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
- ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall2)
+ ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall2)
assert actor.IsActingUpon[0].RelatedObjects == (wall, wall2)
def test_not_assigning_twice(self):
wall = self.file.createIfcWall()
actor = self.file.createIfcActor()
- ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
- ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
+ ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
+ ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
diff --git a/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py b/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
index a9a60472bb..839f46ea73 100644
--- a/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
+++ b/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
@@ -26,14 +26,14 @@ import ifcopenshell.api.owner.settings
class TestCreateOwnerHistory(test.bootstrap.IFC4):
def test_creating_nothing_if_no_user_or_application_is_available(self):
if self.file.schema != "IFC2X3":
- history = ifcopenshell.api.run("owner.create_owner_history", self.file)
+ history = ifcopenshell.api.owner.create_owner_history(self.file)
assert history is None
else:
ifcopenshell.api.owner.settings.factory_reset()
# create new file as bootstrap is creating users in ifc2x3 by default
file = ifcopenshell.file(schema="IFC2X3")
with pytest.raises(Exception) as e:
- ifcopenshell.api.run("owner.create_owner_history", file)
+ ifcopenshell.api.owner.create_owner_history(file)
assert "Please create a user to continue" in str(e.value)
ifcopenshell.api.owner.settings.restore()
@@ -44,7 +44,7 @@ class TestCreateOwnerHistory(test.bootstrap.IFC4):
application = self.file.createIfcApplication()
ifcopenshell.api.owner.settings.get_user = lambda x: user
ifcopenshell.api.owner.settings.get_application = lambda x: application
- history = ifcopenshell.api.run("owner.create_owner_history", self.file)
+ history = ifcopenshell.api.owner.create_owner_history(self.file)
ifcopenshell.api.owner.settings.restore()
assert history.is_a("IfcOwnerHistory")
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_actor.py b/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
index de30e7ba29..02335cca41 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
@@ -17,15 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestEditActor(test.bootstrap.IFC4):
def test_editing_an_actor(self):
person = self.file.createIfcPerson()
- actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
- ifcopenshell.api.run(
- "owner.edit_actor",
+ actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
+ ifcopenshell.api.owner.edit_actor(
self.file,
actor=actor,
attributes={"Name": "Name", "Description": "Description", "ObjectType": "ObjectType"},
@@ -36,9 +35,8 @@ class TestEditActor(test.bootstrap.IFC4):
def test_editing_an_occupant(self):
person = self.file.createIfcPerson()
- actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
- ifcopenshell.api.run(
- "owner.edit_actor",
+ actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
+ ifcopenshell.api.owner.edit_actor(
self.file,
actor=actor,
attributes={
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_address.py b/src/ifcopenshell-python/test/api/owner/test_edit_address.py
index c7a69db019..c01b072939 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_address.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestEditAddress(test.bootstrap.IFC4):
def test_editing_a_postal_address(self):
address = self.file.createIfcPostalAddress()
- ifcopenshell.api.run(
- "owner.edit_address",
+ ifcopenshell.api.owner.edit_address(
self.file,
address=address,
attributes={
@@ -66,8 +65,7 @@ class TestEditAddress(test.bootstrap.IFC4):
if self.file.schema != "IFC2X3":
attributes["MessagingIDs"] = ["Messaging", "IDs"]
- ifcopenshell.api.run(
- "owner.edit_address",
+ ifcopenshell.api.owner.edit_address(
self.file,
address=address,
attributes=attributes,
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py b/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
index 8ec224dd25..65eb525a73 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestEditOrganisation(test.bootstrap.IFC4):
def test_editing_a_organisation(self):
organisation = self.file.createIfcOrganization()
- ifcopenshell.api.run(
- "owner.edit_organisation",
+ ifcopenshell.api.owner.edit_organisation(
self.file,
organisation=organisation,
attributes={
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_person.py b/src/ifcopenshell-python/test/api/owner/test_edit_person.py
index 0d5d8a2c97..e1b79ddc6e 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_person.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestEditPerson(test.bootstrap.IFC4):
def test_editing_a_person(self):
person = self.file.createIfcPerson()
- ifcopenshell.api.run(
- "owner.edit_person",
+ ifcopenshell.api.owner.edit_person(
self.file,
person=person,
attributes={
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_role.py b/src/ifcopenshell-python/test/api/owner/test_edit_role.py
index 693ff29c5b..c92f38d15c 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_role.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestEditRole(test.bootstrap.IFC4):
def test_editing_a_role(self):
role = self.file.createIfcActorRole()
- ifcopenshell.api.run(
- "owner.edit_role",
+ ifcopenshell.api.owner.edit_role(
self.file,
role=role,
attributes={"Role": "ARCHITECT", "UserDefinedRole": "UserDefinedRole", "Description": "Description"},
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_actor.py b/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
index b3a387f2e6..f46b70ca6e 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
@@ -17,14 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestRemoveActor(test.bootstrap.IFC4):
def test_removing_an_actor(self):
person = self.file.createIfcPerson()
- actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
- ifcopenshell.api.run("owner.remove_actor", self.file, actor=actor)
+ actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
+ ifcopenshell.api.owner.remove_actor(self.file, actor=actor)
assert len(self.file.by_type("IfcActor")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_address.py b/src/ifcopenshell-python/test/api/owner/test_remove_address.py
index d0a26a10aa..f8d6c6094f 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_address.py
@@ -17,29 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestRemoveAddress(test.bootstrap.IFC4):
def test_removing_an_address(self):
postal = self.file.createIfcPostalAddress()
telecom = self.file.createIfcTelecomAddress()
- ifcopenshell.api.run("owner.remove_address", self.file, address=postal)
- ifcopenshell.api.run("owner.remove_address", self.file, address=telecom)
+ ifcopenshell.api.owner.remove_address(self.file, address=postal)
+ ifcopenshell.api.owner.remove_address(self.file, address=telecom)
assert len(self.file.by_type("IfcAddress")) == 0
def test_ensuring_organisation_cardinality_is_valid(self):
address = self.file.createIfcPostalAddress()
organisation = self.file.createIfcOrganization()
organisation.Addresses = [address]
- ifcopenshell.api.run("owner.remove_address", self.file, address=address)
+ ifcopenshell.api.owner.remove_address(self.file, address=address)
assert organisation.Addresses is None
def test_ensuring_person_cardinality_is_valid(self):
address = self.file.createIfcPostalAddress()
person = self.file.createIfcPerson()
person.Addresses = [address]
- ifcopenshell.api.run("owner.remove_address", self.file, address=address)
+ ifcopenshell.api.owner.remove_address(self.file, address=address)
assert person.Addresses is None
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py b/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
index 232b74795c..7da306ecf3 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
@@ -17,14 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_organisation(self):
organisation = self.file.createIfcOrganization()
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 0
def test_removing_roles_and_addresses_only_used_by_the_organisation(self):
@@ -33,7 +33,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
organisation = self.file.createIfcOrganization()
organisation.Roles = [role]
organisation.Addresses = [address]
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 0
assert len(self.file.by_type("IfcActorRole")) == 0
assert len(self.file.by_type("IfcPostalAddress")) == 0
@@ -47,7 +47,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
organisation.Addresses = [address]
organisation2.Roles = [role]
organisation2.Addresses = [address]
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganization")) == 1
assert len(self.file.by_type("IfcActorRole")) == 1
assert len(self.file.by_type("IfcPostalAddress")) == 1
@@ -55,37 +55,37 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_deleting_organisation_relationships_as_the_relating_organisation(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcOrganizationRelationship(RelatingOrganization=organisation)
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
def test_deleting_organisation_relationships_as_the_related_organisation(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcOrganizationRelationship(RelatedOrganizations=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
def test_deleting_person_and_organisations(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcPersonAndOrganization(TheOrganization=organisation)
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=organisation)
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
organisation = self.file.createIfcOrganization()
document_information = self.file.createIfcDocumentInformation(Editors=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert document_information.Editors is None
def test_deleting_an_application(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcApplication(ApplicationDeveloper=organisation)
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcApplication")) == 0
@@ -94,17 +94,17 @@ class TestRemoveOrganisationIFC4(test.bootstrap.IFC4, TestRemoveOrganisationIFC2
def test_deleting_resource_approval_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_person.py b/src/ifcopenshell-python/test/api/owner/test_remove_person.py
index 0f4f6d55da..8304d4b985 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_person.py
@@ -18,14 +18,14 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_person(self):
person = self.file.createIfcPerson()
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 0
def test_removing_roles_and_addresses_only_used_by_the_person(self):
@@ -34,7 +34,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
person = self.file.createIfcPerson()
person.Roles = [role]
person.Addresses = [address]
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 0
assert len(self.file.by_type("IfcActorRole")) == 0
assert len(self.file.by_type("IfcPostalAddress")) == 0
@@ -48,7 +48,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
person.Addresses = [address]
person2.Roles = [role]
person2.Addresses = [address]
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPerson")) == 1
assert len(self.file.by_type("IfcActorRole")) == 1
assert len(self.file.by_type("IfcPostalAddress")) == 1
@@ -56,14 +56,14 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_ensuring_work_controls_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
work_control = self.file.createIfcWorkControl(Creators=[person])
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert work_control.Creators is None
def test_ensuring_inventory_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
inventory = self.file.createIfcInventory(ResponsiblePersons=[person])
inventory_id = inventory.id()
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
if self.file.schema != "IFC2X3":
assert inventory.ResponsiblePersons is None
else:
@@ -73,19 +73,19 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_deleting_person_and_organisations(self):
person = self.file.createIfcPerson()
self.file.createIfcPersonAndOrganization(ThePerson=person)
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
person = self.file.createIfcPerson()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=person)
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
person = self.file.createIfcPerson()
document_information = self.file.createIfcDocumentInformation(Editors=[person])
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert document_information.Editors is None
@@ -94,17 +94,17 @@ class TestRemovePersonIFC4(test.bootstrap.IFC4, TestRemovePersonIFC2X3):
def test_deleting_resource_approval_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[person])
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[person])
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
person = self.file.create_entity("IfcPerson")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[person])
- ifcopenshell.api.run("owner.remove_person", self.file, person=person)
+ ifcopenshell.api.owner.remove_person(self.file, person=person)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py b/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
index 4b0956b126..a07d8dbe6a 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
@@ -17,32 +17,32 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
import ifcopenshell.guid
class TestRemovePersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing(self):
user = self.file.createIfcPersonAndOrganization()
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
def test_deleting_actors(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=user)
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcActor")) == 0
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
user = self.file.createIfcPersonAndOrganization()
document_information = self.file.createIfcDocumentInformation(Editors=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert document_information.Editors is None
def test_deleting_owner_history(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcOwnerHistory(OwningUser=user)
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcOwnerHistory")) == 0
@@ -51,17 +51,17 @@ class TestRemovePersonAndOrganisationIFC4(test.bootstrap.IFC4, TestRemovePersonA
def test_deleting_resource_approval_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
user = self.file.create_entity("IfcPersonAndOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_role.py b/src/ifcopenshell-python/test/api/owner/test_remove_role.py
index 110adbd9bf..5aa45e6645 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_role.py
@@ -17,34 +17,34 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestRemoveRoleIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_role(self):
role = self.file.createIfcActorRole()
- ifcopenshell.api.run("owner.remove_role", self.file, role=role)
+ ifcopenshell.api.owner.remove_role(self.file, role=role)
assert len(self.file.by_type("IfcActorRole")) == 0
def test_ensuring_organisation_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
organisation = self.file.createIfcOrganization()
organisation.Roles = [role]
- ifcopenshell.api.run("owner.remove_role", self.file, role=role)
+ ifcopenshell.api.owner.remove_role(self.file, role=role)
assert organisation.Roles is None
def test_ensuring_person_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
person = self.file.createIfcPerson()
person.Roles = [role]
- ifcopenshell.api.run("owner.remove_role", self.file, role=role)
+ ifcopenshell.api.owner.remove_role(self.file, role=role)
assert person.Roles is None
def test_ensuring_person_and_organisation_cardinality_is_valid(self):
role = self.file.createIfcActorRole()
person_and_organisation = self.file.createIfcPersonAndOrganization()
person_and_organisation.Roles = [role]
- ifcopenshell.api.run("owner.remove_role", self.file, role=role)
+ ifcopenshell.api.owner.remove_role(self.file, role=role)
assert person_and_organisation.Roles is None
@@ -52,17 +52,17 @@ class TestRemoveRoleIFC4(test.bootstrap.IFC4, TestRemoveRoleIFC2X3):
def test_deleting_resource_approval_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
organisation = self.file.create_entity("IfcOrganization")
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py b/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
index 7f0b6f378f..96a21c1a79 100644
--- a/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestUnassignActor(test.bootstrap.IFC4):
def test_unassigning_an_actor(self):
wall = self.file.createIfcWall()
actor = self.file.createIfcActor()
- ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
- ifcopenshell.api.run("owner.unassign_actor", self.file, relating_actor=actor, related_object=wall)
+ ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
+ ifcopenshell.api.owner.unassign_actor(self.file, relating_actor=actor, related_object=wall)
assert len(self.file.by_type("IfcRelAssignsToActor")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py b/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
index 107fb5a0ab..b90eec9882 100644
--- a/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
+++ b/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
@@ -18,7 +18,7 @@
import time
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.owner
class TestUpdateOwnerHistory(test.bootstrap.IFC4):
@@ -32,7 +32,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
ifcopenshell.api.owner.settings.get_application = lambda x: application
element = self.file.createIfcWall()
- history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
+ history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert history.is_a("IfcOwnerHistory")
assert element.OwnerHistory == history
assert history.ChangeAction == "ADDED"
@@ -53,10 +53,10 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
ifcopenshell.api.owner.settings.get_application = lambda x: application
element = self.file.createIfcWall()
- old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
+ old_history = ifcopenshell.api.owner.create_owner_history(self.file)
element.OwnerHistory = old_history
- new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
+ new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert new_history == old_history
assert element.OwnerHistory == new_history
assert new_history.ChangeAction == "MODIFIED"
@@ -78,11 +78,11 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
element = self.file.createIfcWall()
element2 = self.file.createIfcWall()
- old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
+ old_history = ifcopenshell.api.owner.create_owner_history(self.file)
element.OwnerHistory = old_history
element2.OwnerHistory = old_history
- new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
+ new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
assert new_history != old_history
assert element.OwnerHistory == new_history
assert new_history.ChangeAction == "MODIFIED"
@@ -95,7 +95,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
def test_doing_nothing_if_no_history_can_be_updated(self):
person = self.file.createIfcPerson()
- assert ifcopenshell.api.run("owner.update_owner_history", self.file, element=person) == None
+ assert ifcopenshell.api.owner.update_owner_history(self.file, element=person) == None
class TestUpdateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestUpdateOwnerHistory):
diff --git a/src/ifcopenshell-python/test/api/project/test_append_asset.py b/src/ifcopenshell-python/test/api/project/test_append_asset.py
index 552c865fe4..b4aceceed6 100644
--- a/src/ifcopenshell-python/test/api/project/test_append_asset.py
+++ b/src/ifcopenshell-python/test/api/project/test_append_asset.py
@@ -17,48 +17,54 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.cost
+import ifcopenshell.api.void
+import ifcopenshell.api.style
+import ifcopenshell.api.context
+import ifcopenshell.api.project
+import ifcopenshell.api.material
import ifcopenshell.util.element
class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
def test_do_not_append_twice(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ schedule = ifcopenshell.api.cost.add_cost_schedule(library, name="Schedule")
profile = library.createIfcIShapeProfileDef()
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
assert len(self.file.by_type("IfcWallType")) == 1
def test_append_a_type_product(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert len(self.file.by_type("IfcWallType")) == 1
def test_reuse_an_existing_context_if_it_was_added_from_library_previously(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- project = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- lib_context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ project = ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ lib_context = ifcopenshell.api.context.add_context(library, context_type="Model")
self.file.add(project) # will add project and it's contexts
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- style = ifcopenshell.api.run("style.add_style", library)
- ifcopenshell.api.run(
- "style.assign_material_style", library, material=material, style=style, context=lib_context
- )
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ style = ifcopenshell.api.style.add_style(library)
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=lib_context)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
@@ -66,61 +72,61 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
assert context.WorldCoordinateSystem
def test_append_a_single_type_product_even_though_an_inverse_material_relationship_is_shared(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element2], material=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert len(self.file.by_type("IfcWallType")) == 1
def test_append_a_type_product_with_its_materials(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
def test_append_a_type_product_where_its_inverse_material_relationship_refers_to_products_not_in_scope(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element_type], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element_type2], material=material)
# appending another type not connected to IfcWall directly
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element_type2)
assert set(self.file.by_type("IfcWall")) == set()
# appending type of IfcWall
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element_type2)
assert set(self.file.by_type("IfcWall")) == set()
def test_append_two_type_products_sharing_the_same_material_indirectly_via_a_material_set(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element1 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
- layer_set1 = ifcopenshell.api.run("material.add_material_set", library, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set1, material=material)
- ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set1, material=material)
+ layer_set1 = ifcopenshell.api.material.add_material_set(library, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.add_layer(library, layer_set=layer_set1, material=material)
+ ifcopenshell.api.material.add_layer(library, layer_set=layer_set1, material=material)
- layer_set2 = ifcopenshell.api.run("material.add_material_set", library, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
- ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
+ layer_set2 = ifcopenshell.api.material.add_material_set(library, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.add_layer(library, layer_set=layer_set2, material=material)
+ ifcopenshell.api.material.add_layer(library, layer_set=layer_set2, material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element1], material=layer_set1)
- ifcopenshell.api.run("material.assign_material", library, products=[element2], material=layer_set2)
+ ifcopenshell.api.material.assign_material(library, products=[element1], material=layer_set1)
+ ifcopenshell.api.material.assign_material(library, products=[element2], material=layer_set2)
- new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
- new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
+ new1 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element1)
+ new2 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
material = self.file.by_type("IfcMaterial")[0]
assert ifcopenshell.util.element.get_material(new1).MaterialLayers[0].Material == material
@@ -129,13 +135,13 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
assert ifcopenshell.util.element.get_material(new2).MaterialLayers[1].Material == material
def test_append_a_type_product_with_its_styles(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
history = library.createIfcOwnerHistory()
element.OwnerHistory = history
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- rel = ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ rel = ifcopenshell.api.material.assign_material(library, products=[element], material=material)
# We share a history. This ensures that we continue to check all
# whitelisted inverses even though one of the subelements (i.e. this
# shared history) is already processed. See bug #2837.
@@ -145,13 +151,13 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
library.createIfcStyledItem(Item=item)
mapped_rep = library.createIfcShapeRepresentation(Items=[item])
element.RepresentationMaps = [library.createIfcRepresentationMap(MappedRepresentation=mapped_rep)]
- new = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ new = ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert len(new.RepresentationMaps[0].MappedRepresentation.Items[0].StyledByItem) == 1
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
def test_append_product_with_styles_to_reuse_styleditems(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
history = library.createIfcOwnerHistory()
element_type.OwnerHistory = history
item = library.createIfcBoundingBox()
@@ -160,63 +166,63 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
mapped_rep = library.createIfcShapeRepresentation(Items=[item], ContextOfItems=context)
element_type.RepresentationMaps = [library.createIfcRepresentationMap(MappedRepresentation=mapped_rep)]
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert len(self.file.by_type("IfcStyledItem")) == 1
def test_append_a_type_product_with_a_styled_materials(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- local_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ local_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ context = ifcopenshell.api.context.add_context(library, context_type="Model")
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- style = ifcopenshell.api.run("style.add_style", library)
- ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ style = ifcopenshell.api.style.add_style(library)
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.HasRepresentation
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
def test_append_a_material(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
def test_append_a_material_with_a_representation(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- style = ifcopenshell.api.run("style.add_style", library)
- context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
- ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ style = ifcopenshell.api.style.add_style(library)
+ context = ifcopenshell.api.context.add_context(library, context_type="Model")
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
assert context.ContextType == "Model"
def test_append_a_material_with_a_representation_and_reuse_an_existing_context(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- style = ifcopenshell.api.run("style.add_style", library)
- context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
- ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ style = ifcopenshell.api.style.add_style(library)
+ context = ifcopenshell.api.context.add_context(library, context_type="Model")
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
@@ -225,10 +231,9 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
assert context.WorldCoordinateSystem
def test_append_a_material_with_a_representation_and_reuse_an_existing_subcontext(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- file_subcontext = ifcopenshell.api.run(
- "context.add_context",
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ file_subcontext = ifcopenshell.api.context.add_context(
self.file,
parent=file_context,
context_type="Model",
@@ -236,21 +241,20 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
target_view="MODEL_VIEW",
)
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- style = ifcopenshell.api.run("style.add_style", library)
- context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
- subcontext = ifcopenshell.api.run(
- "context.add_context",
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ style = ifcopenshell.api.style.add_style(library)
+ context = ifcopenshell.api.context.add_context(library, context_type="Model")
+ subcontext = ifcopenshell.api.context.add_context(
library,
parent=context,
context_type="Model",
context_identifier="Body",
target_view="MODEL_VIEW",
)
- ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=subcontext)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=subcontext)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext", include_subtypes=False)) == 1
assert len(self.file.by_type("IfcGeometricRepresentationSubContext", include_subtypes=False)) == 1
@@ -260,24 +264,23 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
assert subcontext.ParentContext.WorldCoordinateSystem
def test_append_a_material_with_a_representation_and_reuse_an_existing_context_by_a_new_subcontext(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- style = ifcopenshell.api.run("style.add_style", library)
- context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
- subcontext = ifcopenshell.api.run(
- "context.add_context",
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ style = ifcopenshell.api.style.add_style(library)
+ context = ifcopenshell.api.context.add_context(library, context_type="Model")
+ subcontext = ifcopenshell.api.context.add_context(
library,
context_type="Model",
context_identifier="Body",
target_view="MODEL_VIEW",
parent=context,
)
- ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=subcontext)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
+ ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=subcontext)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext", include_subtypes=False)) == 1
assert len(self.file.by_type("IfcGeometricRepresentationSubContext", include_subtypes=False)) == 1
@@ -288,83 +291,83 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
assert subcontext.ParentContext == file_context
def test_append_a_profile_def(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
profile = library.createIfcIShapeProfileDef()
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
def test_append_a_product(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert len(self.file.by_type("IfcWall")) == 1
def test_append_a_product_with_all_properties(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- ifcopenshell.api.run("pset.add_pset", library, product=element, name="Foo_Bar")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ ifcopenshell.api.pset.add_pset(library, product=element, name="Foo_Bar")
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert ifcopenshell.util.element.get_psets(self.file.by_type("IfcWall")[0])["Foo_Bar"]
def test_append_a_product_with_its_type(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert ifcopenshell.util.element.get_type(self.file.by_type("IfcWall")[0]).is_a("IfcWallType")
def test_append_only_specified_occurrences_of_a_typed_product(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element2], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element3], relating_type=element_type)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element3 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(library, related_objects=[element2], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(library, related_objects=[element3], relating_type=element_type)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
assert len(ifcopenshell.util.element.get_types(self.file.by_type("IfcWallType")[0])) == 2
assert len(self.file.by_type("IfcWall")) == 2
def test_append_a_product_with_materials(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert ifcopenshell.util.element.get_material(self.file.by_type("IfcWall")[0]).Name == "Material"
def test_append_a_product_where_its_inverse_material_relationship_refers_to_product_types_not_in_scope(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
- ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(library, name="Material")
+ ifcopenshell.api.material.assign_material(library, products=[element], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element_type], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element_type2], material=material)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert [e.GlobalId for e in self.file.by_type("IfcWallType")] == [element_type.GlobalId]
def test_append_a_product_with_its_styles(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
item = library.createIfcBoundingBox()
library.createIfcStyledItem(Item=item)
representation = library.createIfcShapeRepresentation(Items=[item])
element.Representation = library.createIfcProductDefinitionShape(Representations=[representation])
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
def test_append_a_product_with_openings(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", library, opening=opening, element=element)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(library, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(library, opening=opening, element=element)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
assert self.file.by_type("IfcWall")[0].HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
@@ -372,28 +375,28 @@ class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
# NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
# and we use it in whitelisted_inverse_attributes for appending IfcProfileDef
def test_append_a_profile_def_with_all_properties(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
profile = library.createIfcIShapeProfileDef()
- ifcopenshell.api.run("pset.add_pset", library, product=profile, name="Foo_Bar")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
+ ifcopenshell.api.pset.add_pset(library, product=profile, name="Foo_Bar")
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
assert self.file.by_type("IfcIShapeProfileDef")[0].HasProperties[0].Name == "Foo_Bar"
# NOTE: breaks in IFC2X3 since IfcMaterial doesn't have "HasProperties" inverse in ifc2x3
# and we use it in whitelisted_inverse_attributes for appending IfcTypeProduct
def test_append_two_type_products_sharing_the_same_material_with_properties(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ element1 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.material.add_material(library, name="Material")
- pset = ifcopenshell.api.run("pset.add_pset", library, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", library, pset=pset, properties={"Foo": "Bar"})
+ pset = ifcopenshell.api.pset.add_pset(library, product=material, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(library, pset=pset, properties={"Foo": "Bar"})
- ifcopenshell.api.run("material.assign_material", library, products=[element1], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
- new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
- new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
+ ifcopenshell.api.material.assign_material(library, products=[element1], material=material)
+ ifcopenshell.api.material.assign_material(library, products=[element2], material=material)
+ new1 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element1)
+ new2 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
assert len(self.file.by_type("IfcMaterialProperties")) == 1
material = self.file.by_type("IfcMaterial")[0]
@@ -404,11 +407,11 @@ class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
# NOTE: breaks in IFC2X3 since IfcCostItem doesn't have "IsNestedBy" inverse in ifc2x3
# and we use it in whitelisted_inverse_attributes for appending IfcCostSchedule
def test_append_a_cost_schedule(self):
- library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
- item = ifcopenshell.api.run("cost.add_cost_item", library, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", library, cost_item=item)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
+ library = ifcopenshell.api.project.create_file(version=self.file.schema)
+ schedule = ifcopenshell.api.cost.add_cost_schedule(library, name="Schedule")
+ item = ifcopenshell.api.cost.add_cost_item(library, cost_schedule=schedule)
+ item2 = ifcopenshell.api.cost.add_cost_item(library, cost_item=item)
+ ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
assert len(self.file.by_type("IfcCostSchedule")) == 1
assert len(self.file.by_type("IfcCostItem")) == 2
assert self.file.by_type("IfcCostSchedule")[0].Name == "Schedule"
diff --git a/src/ifcopenshell-python/test/api/project/test_assign_declaration.py b/src/ifcopenshell-python/test/api/project/test_assign_declaration.py
index ea9f7c1fe1..aa2e48c638 100644
--- a/src/ifcopenshell-python/test/api/project/test_assign_declaration.py
+++ b/src/ifcopenshell-python/test/api/project/test_assign_declaration.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.project
# NOTE: supported only in IFC4+
@@ -29,11 +30,10 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
return definitions
def test_assign_a_declaration(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- ifcopenshell.api.run(
- "project.assign_declaration",
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ ifcopenshell.api.project.assign_declaration(
self.file,
definitions=[element_type, element_type2],
relating_context=library,
@@ -42,29 +42,29 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelDeclares")) == 1
def test_doing_nothing_if_the_library_is_already_assigned(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type, element_type2], relating_context=library
)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type, element_type2], relating_context=library
)
assert len([e for e in self.file]) == total_elements
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type], relating_context=library
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type], relating_context=library
)
rel = self.file.by_type("IfcRelDeclares")[0]
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type2, element_type3], relating_context=library
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type2, element_type3], relating_context=library
)
assert len(rel.RelatedDefinitions) == 3
diff --git a/src/ifcopenshell-python/test/api/project/test_create_file.py b/src/ifcopenshell-python/test/api/project/test_create_file.py
index 630e539721..8b952777cf 100644
--- a/src/ifcopenshell-python/test/api/project/test_create_file.py
+++ b/src/ifcopenshell-python/test/api/project/test_create_file.py
@@ -17,14 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.project
class TestCreateFile(test.bootstrap.IFC4):
def test_run(self):
- ifc = ifcopenshell.api.run("project.create_file")
+ ifc = ifcopenshell.api.project.create_file()
assert ifc.schema == "IFC4"
- ifc = ifcopenshell.api.run("project.create_file", version="IFC2X3")
+ ifc = ifcopenshell.api.project.create_file(version="IFC2X3")
assert ifc.schema == "IFC2X3"
assert ifc.wrapped_data.header.file_name.name == "/dev/null"
assert ifc.wrapped_data.header.file_name.time_stamp
diff --git a/src/ifcopenshell-python/test/api/project/test_unassign_declaration.py b/src/ifcopenshell-python/test/api/project/test_unassign_declaration.py
index 60dd46f7ad..0b10c23f07 100644
--- a/src/ifcopenshell-python/test/api/project/test_unassign_declaration.py
+++ b/src/ifcopenshell-python/test/api/project/test_unassign_declaration.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.project
from typing import Union
@@ -29,14 +30,13 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
return rel.RelatingContext
def test_unassigning_a_definition(self):
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type, element_type2], relating_context=library
)
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
self.file,
definitions=[element_type, element_type2],
relating_context=library,
@@ -45,11 +45,10 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelDeclares")) == 0
def test_doing_nothing_if_there_was_no_declaration(self):
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.project.unassign_declaration(
self.file,
definitions=[element_type, element_type2],
relating_context=library,
@@ -58,23 +57,21 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
assert self.get_context(element_type2) == None
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
- library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
- element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run(
- "project.assign_declaration", self.file, definitions=[element_type1], relating_context=library
+ library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
+ element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.project.assign_declaration(
+ self.file, definitions=[element_type1], relating_context=library
)
rel = self.file.by_type("IfcRelDeclares")[0]
- ifcopenshell.api.run(
- "project.assign_declaration",
+ ifcopenshell.api.project.assign_declaration(
self.file,
definitions=[element_type2, element_type3],
relating_context=library,
)
- ifcopenshell.api.run(
- "project.unassign_declaration",
+ ifcopenshell.api.project.unassign_declaration(
self.file,
definitions=[element_type1, element_type2],
relating_context=library,
diff --git a/src/ifcopenshell-python/test/api/pset/test_add_pset.py b/src/ifcopenshell-python/test/api/pset/test_add_pset.py
index 26c26f26af..1bbd6ef0be 100644
--- a/src/ifcopenshell-python/test/api/pset/test_add_pset.py
+++ b/src/ifcopenshell-python/test/api/pset/test_add_pset.py
@@ -17,48 +17,51 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.profile
+import ifcopenshell.api.material
import ifcopenshell.util.element
class TestAddPset(test.bootstrap.IFC4):
def test_adding_a_pset_to_an_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
assert pset.is_a("IfcPropertySet")
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_pset_to_a_type_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
assert pset.is_a("IfcPropertySet")
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_pset_to_a_material(self):
- material = ifcopenshell.api.run("material.add_material", self.file)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Pset_MaterialCommon")
+ material = ifcopenshell.api.material.add_material(self.file)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Pset_MaterialCommon")
assert pset.is_a("IfcMaterialProperties")
assert pset.Name == "Pset_MaterialCommon"
assert pset.Material == material
def test_adding_a_pset_to_a_profile(self):
- profile = ifcopenshell.api.run("profile.add_parameterized_profile", self.file, ifc_class="IfcCircleProfileDef")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=profile, name="Pset_ProfileMechanical")
+ profile = ifcopenshell.api.profile.add_parameterized_profile(self.file, ifc_class="IfcCircleProfileDef")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=profile, name="Pset_ProfileMechanical")
assert pset.is_a("IfcProfileProperties")
if self.file.schema != "IFC2X3":
assert pset.Name == "Pset_ProfileMechanical"
assert pset.ProfileDefinition == profile
def test_adding_a_pset_to_a_context(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
assert pset.is_a("IfcPropertySet")
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
class TestAddPsetIFC2X3(test.bootstrap.IFC2X3, TestAddPset):
def test_adding_a_pset_to_a_project(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
assert pset.is_a("IfcPropertySet")
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
diff --git a/src/ifcopenshell-python/test/api/pset/test_add_qto.py b/src/ifcopenshell-python/test/api/pset/test_add_qto.py
index 3afb847c89..4c7493ca14 100644
--- a/src/ifcopenshell-python/test/api/pset/test_add_qto.py
+++ b/src/ifcopenshell-python/test/api/pset/test_add_qto.py
@@ -17,33 +17,34 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
import ifcopenshell.util.element
class TestAddQto(test.bootstrap.IFC4):
def test_adding_a_qto_to_an_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
assert qto.is_a("IfcElementQuantity")
assert "Qto_WallBaseQuantities" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_qto_to_a_type_object(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
assert qto.is_a("IfcElementQuantity")
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
def test_adding_a_qto_to_a_context(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
assert qto.is_a("IfcElementQuantity")
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
class TestAddQtoIFC2X3(test.bootstrap.IFC2X3):
def test_adding_a_qto_to_a_project(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
assert qto.is_a("IfcElementQuantity")
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
diff --git a/src/ifcopenshell-python/test/api/pset/test_edit_pset.py b/src/ifcopenshell-python/test/api/pset/test_edit_pset.py
index 5c065495ab..5a45ab489a 100644
--- a/src/ifcopenshell-python/test/api/pset/test_edit_pset.py
+++ b/src/ifcopenshell-python/test/api/pset/test_edit_pset.py
@@ -18,16 +18,16 @@
import operator
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
import ifcopenshell.guid
class TestEditPset(test.bootstrap.IFC4):
def test_editing_a_blank_buildingsmart_templated_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={"Reference": "reference", "Status": ["NEW"], "Combustible": True, "ThermalTransmittance": 42},
@@ -51,16 +51,15 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[3].NominalValue.wrappedValue == 42
def test_editing_an_existing_buildingsmart_templated_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={"Reference": "foo", "Status": ["NEW"], "Combustible": True, "ThermalTransmittance": 42},
)
- ifcopenshell.api.run(
- "pset.edit_pset", self.file, pset=pset, properties={"Reference": "bar", "Status": []}, should_purge=False
+ ifcopenshell.api.pset.edit_pset(
+ self.file, pset=pset, properties={"Reference": "bar", "Status": []}, should_purge=False
)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
@@ -72,15 +71,14 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[1].EnumerationValues is None
def test_editing_a_templated_pset_with_automatic_casting_of_primitive_data_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={"ThermalTransmittance": "42"},
)
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": "bar", "Status": None})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": "bar", "Status": None})
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert pset.HasProperties[0].Name == "ThermalTransmittance"
@@ -88,49 +86,48 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[0].NominalValue.wrappedValue == 42
def test_adding_a_property_if_it_is_none(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=False)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=False)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert len(pset.HasProperties) == 1
def test_not_adding_a_property_if_it_is_none_and_should_purge_is_true(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=True)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=True)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert len(pset.HasProperties) == 0
def test_removing_a_none_property_if_specified(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": "Foo"})
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=True)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": "Foo"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=True)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert len(pset.HasProperties) == 0
def test_removing_a_none_enumeration_property_if_specified(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
assert pset.HasProperties[0].Name == "Status"
assert pset.HasProperties[0].EnumerationValues[0].wrappedValue == "NEW"
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": []}, should_purge=True)
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": []}, should_purge=True)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert len(pset.HasProperties) == 0
def test_editing_a_pset_name(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="foo")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, name="bar")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="foo")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, name="bar")
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
assert pset.Name == "bar"
def test_adding_properties_without_a_template_with_autodetected_and_manual_data_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -164,18 +161,16 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[4].NominalValue.wrappedValue == 123.0
def test_editing_properties_with_autodetected_existing_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
"MyCustom": self.file.createIfcContextDependentMeasure(12),
},
)
- ifcopenshell.api.run(
- "pset.edit_pset",
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -188,12 +183,11 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[0].NominalValue.wrappedValue == 34
def test_editing_list_valued_properties(self):
- cable = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
+ cable = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=cable, name="Pset_DistributionPortTypeCable")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=cable, name="Pset_DistributionPortTypeCable")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -206,18 +200,16 @@ class TestEditPset(test.bootstrap.IFC4):
assert list(map(operator.itemgetter(0), pset.HasProperties[0].ListValues)) == ["One", "Two", "Three"]
def test_editing_properties_with_an_explicit_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
"MyCustom": self.file.createIfcLabel("True"),
},
)
- ifcopenshell.api.run(
- "pset.edit_pset",
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -230,19 +222,17 @@ class TestEditPset(test.bootstrap.IFC4):
assert pset.HasProperties[0].NominalValue.wrappedValue is True
def test_editing_properties_with_custom_units(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
custom_unit = self.file.createIfcSIUnit(UnitType="PRESSUREUNIT", Prefix="GIGA", Name="PASCAL")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
"MyCustom": self.file.createIfcModulusOfElasticityMeasure(20),
},
)
- ifcopenshell.api.run(
- "pset.edit_pset",
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -260,8 +250,8 @@ class TestEditPset(test.bootstrap.IFC4):
def test_editing_properties_of_non_rooted_elements(self):
element = self.file.createIfcMaterial()
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
assert element.HasProperties[0] == pset
assert pset.Properties[0].Name == "foo"
@@ -289,10 +279,9 @@ class TestEditPset(test.bootstrap.IFC4):
],
},
)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
pset_template=template,
@@ -308,15 +297,15 @@ class TestEditPset(test.bootstrap.IFC4):
def test_editing_a_shared_property(self):
element1 = self.file.createIfcMaterial()
element2 = self.file.createIfcMaterial()
- pset1 = ifcopenshell.api.run("pset.add_pset", self.file, product=element1, name="Foo_Bar")
- pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset1, properties={"foo": "bar"})
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset2, properties={"foo2": "bar2"})
+ pset1 = ifcopenshell.api.pset.add_pset(self.file, product=element1, name="Foo_Bar")
+ pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset1, properties={"foo": "bar"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset2, properties={"foo2": "bar2"})
element1.HasProperties[0].Properties = list(element1.HasProperties[0].Properties) + list(
element2.HasProperties[0].Properties
)
assert ifcopenshell.util.element.get_pset(element1, "Foo_Bar", "foo2") == "bar2"
assert ifcopenshell.util.element.get_pset(element2, "Foo_Bar", "foo2") == "bar2"
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset1, properties={"foo2": "bar3"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset1, properties={"foo2": "bar3"})
assert ifcopenshell.util.element.get_pset(element1, "Foo_Bar", "foo2") == "bar3"
assert ifcopenshell.util.element.get_pset(element2, "Foo_Bar", "foo2") == "bar2"
diff --git a/src/ifcopenshell-python/test/api/pset/test_edit_qto.py b/src/ifcopenshell-python/test/api/pset/test_edit_qto.py
index 1800a85662..0dc2bb5ef7 100644
--- a/src/ifcopenshell-python/test/api/pset/test_edit_qto.py
+++ b/src/ifcopenshell-python/test/api/pset/test_edit_qto.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
class TestEditQto(test.bootstrap.IFC4):
def test_editing_a_blank_buildingsmart_templated_qto(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
- ifcopenshell.api.run(
- "pset.edit_qto",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={"Length": 1, "NetSideArea": 2, "NetVolume": 3},
@@ -42,15 +42,14 @@ class TestEditQto(test.bootstrap.IFC4):
assert pset.Quantities[2].VolumeValue == 3
def test_editing_an_existing_buildingsmart_templated_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
- ifcopenshell.api.run(
- "pset.edit_qto",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={"Length": 1, "NetSideArea": 2, "NetVolume": 3},
)
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Length": 42, "NetSideArea": None})
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Length": 42, "NetSideArea": None})
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
assert qto.Quantities[0].Name == "Length"
@@ -62,24 +61,23 @@ class TestEditQto(test.bootstrap.IFC4):
assert len(qto.Quantities) == 2
def test_not_adding_a_property_if_it_is_none(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Length": None})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Length": None})
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
assert len(qto.Quantities) == 0
def test_editing_a_qto_name(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="foo")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, name="bar")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="foo")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, name="bar")
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
assert qto.Name == "bar"
def test_adding_quantities_without_a_template_with_autodetected_and_manual_data_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_qto",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={
@@ -112,18 +110,16 @@ class TestEditQto(test.bootstrap.IFC4):
assert qto.Quantities[5].WeightValue == 7
def test_editing_quantities_with_autodetected_existing_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_qto",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={
"MyLength": self.file.createIfcLengthMeasure(12),
},
)
- ifcopenshell.api.run(
- "pset.edit_qto",
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={
@@ -135,18 +131,16 @@ class TestEditQto(test.bootstrap.IFC4):
assert qto.Quantities[0].LengthValue == 34
def test_editing_properties_with_an_explicit_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run(
- "pset.edit_qto",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={
"MyLength": self.file.createIfcLengthMeasure(12),
},
)
- ifcopenshell.api.run(
- "pset.edit_qto",
+ ifcopenshell.api.pset.edit_qto(
self.file,
qto=qto,
properties={
diff --git a/src/ifcopenshell-python/test/api/pset/test_remove_pset.py b/src/ifcopenshell-python/test/api/pset/test_remove_pset.py
index 134bf1b9a7..bb154cfc4f 100644
--- a/src/ifcopenshell-python/test/api/pset/test_remove_pset.py
+++ b/src/ifcopenshell-python/test/api/pset/test_remove_pset.py
@@ -17,94 +17,95 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
import ifcopenshell.util.element
class TestRemovePset(test.bootstrap.IFC4):
def test_removing_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 1
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
assert len(self.file.by_type("IfcPropertySet")) == 0
def test_removing_material_psets(self):
element = self.file.createIfcMaterial()
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
assert len(element.HasProperties) == 1
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(element.HasProperties) == 0
assert len(self.file.by_type("IfcMaterialProperties")) == 0
def test_removing_profile_psets(self):
element = self.file.createIfcProfileDef()
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
assert len(element.HasProperties) == 1
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(element.HasProperties) == 0
assert len(self.file.by_type("IfcMaterialProperties")) == 0
def test_only_unassigning_if_pset_is_used_by_other_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
rel = self.file.by_type("IfcRelDefinesByProperties")[0]
rel.RelatedObjects = [element, element2]
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 1
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert ifcopenshell.util.element.get_psets(element) == {}
assert "Foo_Bar" in ifcopenshell.util.element.get_psets(element2)
def test_removing_a_pset_with_properties(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
assert len(self.file.by_type("IfcPropertySet")) == 0
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
def test_removing_a_qto_with_quantities(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Foo": 42})
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=qto)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Foo": 42})
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=qto)
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
assert len(self.file.by_type("IfcQuantitySet")) == 0
assert len(self.file.by_type("IfcPhysicalSimpleQuantity")) == 0
def test_removing_a_pset_with_shared_properties(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
pset2.HasProperties = pset.HasProperties
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert pset2.HasProperties
def test_removing_a_pset_with_enumeration(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(self.file.by_type("IfcPropertyEnumeration")) == 0
def test_removing_a_pset_with_shared_enumeration(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset2, properties={"Status": ["NEW"]})
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset2, properties={"Status": ["NEW"]})
enumeration1 = pset.HasProperties[0].EnumerationReference
enumeration2 = pset2.HasProperties[0].EnumerationReference
pset2.HasProperties[0].EnumerationReference = enumeration1
self.file.remove(enumeration2)
- ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
+ ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
assert len(self.file.by_type("IfcPropertyEnumeration")) == 1
diff --git a/src/ifcopenshell-python/test/api/pset_template/test_edit_prop_template.py b/src/ifcopenshell-python/test/api/pset_template/test_edit_prop_template.py
index 18522189fc..1ff555f6b4 100644
--- a/src/ifcopenshell-python/test/api/pset_template/test_edit_prop_template.py
+++ b/src/ifcopenshell-python/test/api/pset_template/test_edit_prop_template.py
@@ -17,42 +17,38 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset_template
class TestEditPropTemplate(test.bootstrap.IFC4):
def test_editing_a_simple_template(self):
- template = ifcopenshell.api.run("pset_template.add_pset_template", self.file, name="ABC_RiskFactors")
- prop = ifcopenshell.api.run("pset_template.add_prop_template", self.file, pset_template=template)
- ifcopenshell.api.run(
- "pset_template.edit_prop_template",
+ template = ifcopenshell.api.pset_template.add_pset_template(self.file, name="ABC_RiskFactors")
+ prop = ifcopenshell.api.pset_template.add_prop_template(self.file, pset_template=template)
+ ifcopenshell.api.pset_template.edit_prop_template(
self.file,
prop_template=prop,
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
)
- ifcopenshell.api.run(
- "pset_template.edit_prop_template", self.file, prop_template=prop, attributes={"Name": "DemoB"}
+ ifcopenshell.api.pset_template.edit_prop_template(
+ self.file, prop_template=prop, attributes={"Name": "DemoB"}
)
assert prop.Name == "DemoB"
def test_editing_an_enumeration(self):
- template = ifcopenshell.api.run("pset_template.add_pset_template", self.file, name="ABC_RiskFactors")
- prop = ifcopenshell.api.run("pset_template.add_prop_template", self.file, pset_template=template)
- ifcopenshell.api.run(
- "pset_template.edit_prop_template",
+ template = ifcopenshell.api.pset_template.add_pset_template(self.file, name="ABC_RiskFactors")
+ prop = ifcopenshell.api.pset_template.add_prop_template(self.file, pset_template=template)
+ ifcopenshell.api.pset_template.edit_prop_template(
self.file,
prop_template=prop,
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
)
- ifcopenshell.api.run(
- "pset_template.edit_prop_template",
+ ifcopenshell.api.pset_template.edit_prop_template(
self.file,
prop_template=prop,
attributes={"Enumerators": ["FOO", "BAR"]},
)
assert prop.Enumerators.EnumerationValues == tuple(self.file.createIfcLabel(v) for v in ("FOO", "BAR"))
- ifcopenshell.api.run(
- "pset_template.edit_prop_template",
+ ifcopenshell.api.pset_template.edit_prop_template(
self.file,
prop_template=prop,
attributes={"Name": "DemoC", "Enumerators": ["BAZ", "BAR"]},
diff --git a/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py b/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py
index e81e47f2fc..c80e3dae28 100644
--- a/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py
+++ b/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py
@@ -17,7 +17,10 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.resource
+import ifcopenshell.api.sequence
import ifcopenshell.util.constraint
@@ -25,12 +28,11 @@ import ifcopenshell.util.constraint
# therefore no IFC2X3 tests
class TestCalculateResourceWork(test.bootstrap.IFC4):
def test_calculating_resource_work_based_on_a_daily_productivity_rate(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -40,23 +42,22 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
},
)
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
assert resource.Usage.ScheduleWork == "P2.0D"
def test_calculating_resource_work_based_on_an_hourly_productivity_rate(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -66,46 +67,45 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
},
)
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
assert resource.Usage.ScheduleWork == "PT4.0H"
def test_no_calculation_if_no_productivity_data_available(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
assert resource.Usage is None
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"BaseQuantityProducedName": "foo"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"BaseQuantityProducedName": "foo"})
- ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
assert resource.Usage is None
def test_calculating_resource_work_based_on_a_counted_quantity(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
- ifcopenshell.api.run(
- "pset.edit_pset",
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
+ ifcopenshell.api.pset.edit_pset(
self.file,
pset=pset,
properties={
@@ -115,15 +115,15 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
},
)
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=resource)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=resource)
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
assert resource.Usage.ScheduleWork == "PT0.5H"
diff --git a/src/ifcopenshell-python/test/api/root/test_copy_class.py b/src/ifcopenshell-python/test/api/root/test_copy_class.py
index 25e2b06345..01175eb762 100644
--- a/src/ifcopenshell-python/test/api/root/test_copy_class.py
+++ b/src/ifcopenshell-python/test/api/root/test_copy_class.py
@@ -18,38 +18,47 @@
import numpy
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.type
+import ifcopenshell.api.root
+import ifcopenshell.api.void
+import ifcopenshell.api.pset
+import ifcopenshell.api.group
+import ifcopenshell.api.system
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
import ifcopenshell.util
import ifcopenshell.util.system
class TestCopyClass(test.bootstrap.IFC4):
def test_copying_a_simple_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new != element
assert new.GlobalId != element.GlobalId
assert new.is_a("IfcWall")
def test_copying_object_placements_so_children_of_the_original_element_dont_reference_the_new_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
matrix = numpy.identity(4)
- ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy())
- ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=subelement, matrix=matrix.copy())
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy())
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=subelement, matrix=matrix.copy())
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
assert subelement.ObjectPlacement.PlacementRelTo != new.ObjectPlacement
assert element.ObjectPlacement.RelativePlacement != new.ObjectPlacement.RelativePlacement
def test_copying_psets_so_changing_properties_of_the_new_element_does_not_affect_the_old(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
new_pset = new.IsDefinedBy[0].RelatingPropertyDefinition
assert element.IsDefinedBy[0] != new.IsDefinedBy[0]
@@ -60,10 +69,10 @@ class TestCopyClass(test.bootstrap.IFC4):
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
def test_copying_type_psets_so_changing_properties_of_the_new_type_does_not_affect_the_old(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
pset = element.HasPropertySets[0]
new_pset = new.HasPropertySets[0]
assert element.HasPropertySets[0] != new.HasPropertySets[0]
@@ -74,128 +83,128 @@ class TestCopyClass(test.bootstrap.IFC4):
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
def test_copying_a_container_only_and_not_its_contents(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert element.ContainsElements
assert not new.ContainsElements
def test_copying_contents_of_a_container_and_maintaining_the_containment_relationship(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=subelement)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=subelement)
assert new.ContainedInStructure[0].RelatingStructure == element
def test_copying_a_container_only_and_not_its_decomposition(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert element.IsDecomposedBy
assert not new.IsDecomposedBy
def test_copying_an_aggregate_only_and_not_its_decomposition(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert element.IsDecomposedBy
assert not new.IsDecomposedBy
def test_copying_an_aggregate_decomposition_and_maintaining_the_aggregate_relationship(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=subelement)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=subelement)
assert new.Decomposes[0].RelatingObject == element
def test_not_copying_any_representations_because_life_is_hard(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Representation = self.file.createIfcProductDefinitionShape()
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new.Representation is None
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
element.RepresentationMaps = [self.file.createIfcRepresentationMap()]
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new.RepresentationMaps is None
def test_copying_an_element_with_an_opening(self):
# IfcOpeningElement opening
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=wall)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ new = ifcopenshell.api.root.copy_class(self.file, product=wall)
assert wall.HasOpenings[0] != new.HasOpenings[0]
assert wall.HasOpenings[0].RelatedOpeningElement == opening
assert new.HasOpenings[0].RelatedOpeningElement != opening
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
# IfcVoidingFeature opening
- plate = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPlate")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcVoidingFeature")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=plate)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=plate)
+ plate = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPlate")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcVoidingFeature")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=plate)
+ new = ifcopenshell.api.root.copy_class(self.file, product=plate)
assert plate.HasOpenings[0] != new.HasOpenings[0]
assert plate.HasOpenings[0].RelatedOpeningElement == opening
assert new.HasOpenings[0].RelatedOpeningElement != opening
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcVoidingFeature")
def test_copying_an_element_with_a_filled_opening_should_not_copy_the_opening_nor_fill(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- window = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindow")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=window)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=wall)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ window = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindow")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=window)
+ new = ifcopenshell.api.root.copy_class(self.file, product=wall)
assert not new.HasOpenings
def test_copying_an_opening_voiding_an_element(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ new = ifcopenshell.api.root.copy_class(self.file, product=opening)
assert opening.VoidsElements[0] != new.VoidsElements[0]
assert new.VoidsElements[0].RelatingBuildingElement == wall
def test_copying_an_opening_with_a_filling(self):
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
+ new = ifcopenshell.api.root.copy_class(self.file, product=opening)
assert not new.HasFillings
def test_copying_a_filling(self):
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=door)
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
+ new = ifcopenshell.api.root.copy_class(self.file, product=door)
assert not new.FillsVoids
def test_retaining_a_single_material(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
material = self.file.createIfcMaterial()
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new.HasAssociations[0].RelatingMaterial == element.HasAssociations[0].RelatingMaterial
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterial")
def test_copying_material_set_usages(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
material = self.file.createIfcMaterialLayerSetUsage()
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSetUsage")
def test_copying_material_sets_for_type_elements_only(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
single_material = self.file.createIfcMaterial()
layer = self.file.createIfcMaterialLayer(Material=single_material)
material = self.file.createIfcMaterialLayerSet(MaterialLayers=[layer])
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSet")
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
assert (
@@ -208,25 +217,25 @@ class TestCopyClass(test.bootstrap.IFC4):
)
def test_copying_a_type_and_purging_type_relationships(self):
- type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=type)
+ type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type)
+ new = ifcopenshell.api.root.copy_class(self.file, product=type)
assert not new.Types
def test_copying_distribution_ports(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
- port = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcChiller")
+ port = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="NOTDEFINED")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcChiller")
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="NOTDEFINED")
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
new_ports = ifcopenshell.util.system.get_ports(new)
assert port not in new_ports
assert new_ports[0].is_a("IfcDistributionPort")
@@ -235,17 +244,16 @@ class TestCopyClass(test.bootstrap.IFC4):
assert not ifcopenshell.util.system.get_connected_port(new_ports[0])
def test_not_copying_path_connections(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "geometry.connect_path",
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_path(
self.file,
relating_element=element1,
related_element=element2,
relating_connection="ATSTART",
related_connection="ATEND",
)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element1)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element1)
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
assert element1.ConnectedTo
assert element2.ConnectedFrom
@@ -253,20 +261,20 @@ class TestCopyClass(test.bootstrap.IFC4):
assert not new.ConnectedFrom
def test_maintaining_group_relationships(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file)
- ifcopenshell.api.run("group.assign_group", self.file, group=group, products=[element])
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file)
+ ifcopenshell.api.group.assign_group(self.file, group=group, products=[element])
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
assert new.HasAssignments[0].RelatingGroup == group
class TestCopyClassIFC2X3(test.bootstrap.IFC2X3):
def test_copying_distribution_ports(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
- port = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
- new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowTerminal")
+ port = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
+ new = ifcopenshell.api.root.copy_class(self.file, product=element)
new_ports = ifcopenshell.util.system.get_ports(new)
assert port not in new_ports
assert new_ports[0].is_a("IfcDistributionPort")
diff --git a/src/ifcopenshell-python/test/api/root/test_create_entity.py b/src/ifcopenshell-python/test/api/root/test_create_entity.py
index 9ec93d8933..dbe27a3a51 100644
--- a/src/ifcopenshell-python/test/api/root/test_create_entity.py
+++ b/src/ifcopenshell-python/test/api/root/test_create_entity.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
class TestCreateEntity(test.bootstrap.IFC4):
def test_creating_a_simple_entity_with_automatic_global_id(self):
- wall = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
+ wall = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
)
assert wall.is_a() == "IfcRailing"
assert len(wall.GlobalId) == 22
@@ -31,48 +31,48 @@ class TestCreateEntity(test.bootstrap.IFC4):
assert wall.PredefinedType == "HANDRAIL"
def test_handling_predefined_types(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRailing", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRailing", name="Foo")
assert element.PredefinedType is None
- element = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
+ element = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
)
assert element.PredefinedType == "HANDRAIL"
- element = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="Foobar", name="Foo"
+ element = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcRailing", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ObjectType == "Foobar"
- element = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcWallType", predefined_type="Foobar", name="Foo"
+ element = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcWallType", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ElementType == "Foobar"
if self.file.schema != "IFC2X3":
- element = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
+ element = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ProcessType == "Foobar"
def test_setting_default_values_for_validity(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType", name="Foo")
assert element.PredefinedType == "NOTDEFINED"
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorStyle", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoorStyle", name="Foo")
assert element.OperationType == "NOTDEFINED"
assert element.ConstructionType == "NOTDEFINED"
assert element.ParameterTakesPrecedence == False
assert element.Sizeable == False
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowStyle", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindowStyle", name="Foo")
assert element.OperationType == "NOTDEFINED"
assert element.ConstructionType == "NOTDEFINED"
assert element.ParameterTakesPrecedence == False
assert element.Sizeable == False
if self.file.schema != "IFC2X3":
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorType", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoorType", name="Foo")
assert element.OperationType == "NOTDEFINED"
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowType", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindowType", name="Foo")
assert element.PartitioningType == "NOTDEFINED"
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFurnitureType", name="Foo")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFurnitureType", name="Foo")
assert element.AssemblyPlace == "NOTDEFINED"
diff --git a/src/ifcopenshell-python/test/api/root/test_reassign_class.py b/src/ifcopenshell-python/test/api/root/test_reassign_class.py
index 80276686e9..87cf46656d 100644
--- a/src/ifcopenshell-python/test/api/root/test_reassign_class.py
+++ b/src/ifcopenshell-python/test/api/root/test_reassign_class.py
@@ -17,52 +17,53 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.type
+import ifcopenshell.api.root
import ifcopenshell.util.element
class TestReassignClass(test.bootstrap.IFC4):
def test_reassigning_a_simple_class(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
n_elements = len([e for e in self.file])
original_id = element.id()
- new = ifcopenshell.api.run("root.reassign_class", self.file, product=element, ifc_class="IfcSlab")
+ new = ifcopenshell.api.root.reassign_class(self.file, product=element, ifc_class="IfcSlab")
assert len([e for e in self.file]) == n_elements
assert new.id() == original_id
assert new.is_a("IfcSlab")
def test_reassigning_a_predefined_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- new = ifcopenshell.api.run(
- "root.reassign_class", self.file, product=element, ifc_class="IfcSlab", predefined_type="FLOOR"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ new = ifcopenshell.api.root.reassign_class(
+ self.file, product=element, ifc_class="IfcSlab", predefined_type="FLOOR"
)
assert new.PredefinedType == "FLOOR"
def test_falling_back_to_userdefined_if_the_predefined_type_cannot_be_reassigned_for_occurrence_class(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- new = ifcopenshell.api.run(
- "root.reassign_class", self.file, product=element, ifc_class="IfcSlab", predefined_type="FOO"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ new = ifcopenshell.api.root.reassign_class(
+ self.file, product=element, ifc_class="IfcSlab", predefined_type="FOO"
)
assert new.PredefinedType == "USERDEFINED"
assert new.ObjectType == "FOO"
def test_falling_back_to_userdefined_if_the_predefined_type_cannot_be_reassigned_for_type_class(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- new = ifcopenshell.api.run(
- "root.reassign_class", self.file, product=element, ifc_class="IfcSlabType", predefined_type="FOO"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ new = ifcopenshell.api.root.reassign_class(
+ self.file, product=element, ifc_class="IfcSlabType", predefined_type="FOO"
)
assert new.PredefinedType == "USERDEFINED"
assert new.ElementType == "FOO"
def test_reassign_class_for_type_occurrences(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
- element_type = ifcopenshell.api.run(
- "root.reassign_class", self.file, product=element_type, ifc_class="IfcSlabType"
+ element_type = ifcopenshell.api.root.reassign_class(
+ self.file, product=element_type, ifc_class="IfcSlabType"
)
# type occurrences have reassigned classes
@@ -75,13 +76,13 @@ class TestReassignClass(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWallType")) == 0
def test_reassigning_type_class_and_its_occurrences_classes_if_entity_was_typed(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
- element1 = ifcopenshell.api.run("root.reassign_class", self.file, product=element1, ifc_class="IfcSlab")
+ element1 = ifcopenshell.api.root.reassign_class(self.file, product=element1, ifc_class="IfcSlab")
# occurrence type has reassigned class
element_type = ifcopenshell.util.element.get_type(element1)
diff --git a/src/ifcopenshell-python/test/api/root/test_remove_product.py b/src/ifcopenshell-python/test/api/root/test_remove_product.py
index 176d39be25..7b6cef8295 100644
--- a/src/ifcopenshell-python/test/api/root/test_remove_product.py
+++ b/src/ifcopenshell-python/test/api/root/test_remove_product.py
@@ -17,68 +17,83 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.nest
+import ifcopenshell.api.root
+import ifcopenshell.api.void
+import ifcopenshell.api.grid
+import ifcopenshell.api.type
+import ifcopenshell.api.pset
+import ifcopenshell.api.group
+import ifcopenshell.api.owner
+import ifcopenshell.api.system
+import ifcopenshell.api.spatial
+import ifcopenshell.api.drawing
+import ifcopenshell.api.context
+import ifcopenshell.api.geometry
+import ifcopenshell.api.material
+import ifcopenshell.api.aggregate
import ifcopenshell.guid
class TestRemoveProduct(test.bootstrap.IFC4):
def test_removing_an_element_by_itself(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcWall")) == 0
def test_removing_an_element_local_placement(self):
# just removing the product with the placement
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcObjectPlacement")) == 0
# removing the product that shares the placement with other product
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element1.ObjectPlacement = placement
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcObjectPlacement")) == 1
- ifcopenshell.api.run("root.remove_product", self.file, product=element1)
+ ifcopenshell.api.root.remove_product(self.file, product=element1)
assert len(self.file.by_type("IfcObjectPlacement")) == 0
# removing the product that's placement used as a reference point for another placement
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- placement1 = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element1)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ placement1 = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1)
placement.PlacementRelTo = placement1
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcObjectPlacement")) == 1
- ifcopenshell.api.run("root.remove_product", self.file, product=element1)
+ ifcopenshell.api.root.remove_product(self.file, product=element1)
assert len(self.file.by_type("IfcObjectPlacement")) == 0
def test_removing_element_type_psets(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
element2.HasPropertySets = (pset,)
# make sure it won't remove the pset if it's connected elsewhere
- ifcopenshell.api.run("root.remove_product", self.file, product=element2)
+ ifcopenshell.api.root.remove_product(self.file, product=element2)
assert len(self.file.by_type("IfcPropertySet")) == 1
assert len(self.file.by_type("IfcPropertySingleValue")) == 1
# if it's the product is the only inverse for pset, it should remove the pset
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcPropertySet")) == 0
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
def test_removing_all_representations_of_an_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
total_entities = len(list(self.file))
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Representation = self.file.createIfcProductDefinitionShape(
Representations=[
self.file.createIfcShapeRepresentation(
@@ -86,7 +101,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
)
]
)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
@@ -94,10 +109,10 @@ class TestRemoveProduct(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWall")) == 0
def test_unassigning_but_not_removing_mapped_representations_of_an_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
rep_map = self.file.createIfcRepresentationMap(
MappingOrigin=self.file.createIfcAxis2Placement3D(),
MappedRepresentation=self.file.createIfcShapeRepresentation(
@@ -106,10 +121,9 @@ class TestRemoveProduct(test.bootstrap.IFC4):
)
element_type.RepresentationMaps = [rep_map]
total_entities = len(list(self.file))
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
# should_map_representations=False to create mapping manually
- ifcopenshell.api.run(
- "type.assign_type",
+ ifcopenshell.api.type.assign_type(
self.file,
related_objects=[element],
relating_type=element_type,
@@ -129,7 +143,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
]
)
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
@@ -138,329 +152,316 @@ class TestRemoveProduct(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWall")) == 0
def test_removing_an_element_type_by_itself(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(self.file.by_type("IfcWallType")) == 0
def test_removing_all_openings_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == 0
assert len(self.file.by_type("IfcWall")) == 0
assert len(self.file.by_type("IfcOpeningElement")) == 0
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
def test_removing_axes_of_a_grid(self):
- grid = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcGrid")
- axis = ifcopenshell.api.run("grid.create_grid_axis", self.file, uvw_axes="UAxes", grid=grid)
+ grid = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcGrid")
+ axis = ifcopenshell.api.grid.create_grid_axis(self.file, uvw_axes="UAxes", grid=grid)
axis.AxisCurve = self.file.createIfcPolyline()
- axis = ifcopenshell.api.run("grid.create_grid_axis", self.file, uvw_axes="VAxes", grid=grid)
+ axis = ifcopenshell.api.grid.create_grid_axis(self.file, uvw_axes="VAxes", grid=grid)
axis.AxisCurve = self.file.createIfcPolyline()
total_entities = len(list(self.file))
- ifcopenshell.api.run("root.remove_product", self.file, product=grid)
+ ifcopenshell.api.root.remove_product(self.file, product=grid)
assert len(list(self.file)) == 0
def test_removing_all_void_relationships_of_an_opening(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
total_entities = len(list(self.file))
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=opening)
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
+ ifcopenshell.api.root.remove_product(self.file, product=opening)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcOpeningElement")) == 0
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
def test_removing_all_fill_relationships_of_a_filling(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- filling = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ filling = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
total_entities = len(list(self.file))
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=filling)
- ifcopenshell.api.run("root.remove_product", self.file, product=filling)
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=filling)
+ ifcopenshell.api.root.remove_product(self.file, product=filling)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcDoor")) == 0
assert len(self.file.by_type("IfcRelFillsElement")) == 0
def test_removing_all_distribution_ports(self):
total_entities = len(list(self.file))
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- port = ifcopenshell.api.run("system.add_port", self.file, element=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ port = ifcopenshell.api.system.add_port(self.file, element=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcFlowSegment")) == 0
assert len(self.file.by_type("IfcRelNests")) == 0
assert len(self.file.by_type("IfcDistributionPort")) == 0
def test_removing_all_nesting_relationships_of_a_whole(self):
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
total_entities = len(list(self.file))
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelNests")) == 0
assert len(self.file.by_type("IfcWall")) == 0
assert len(self.file.by_type("IfcBeam")) == 1
def test_removing_all_nesting_relationships_of_a_part(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
total_entities = len(list(self.file))
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
+ ifcopenshell.api.root.remove_product(self.file, product=subelement)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelNests")) == 0
assert len(self.file.by_type("IfcWall")) == 1
assert len(self.file.by_type("IfcBeam")) == 0
def test_removing_all_aggregate_relationships_of_a_whole(self):
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
total_entities = len(list(self.file))
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelAggregates")) == 0
assert len(self.file.by_type("IfcElementAssembly")) == 0
assert len(self.file.by_type("IfcBeam")) == 1
def test_removing_all_aggregate_relationships_of_a_part(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
total_entities = len(list(self.file))
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
+ ifcopenshell.api.root.remove_product(self.file, product=subelement)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelAggregates")) == 0
assert len(self.file.by_type("IfcElementAssembly")) == 1
assert len(self.file.by_type("IfcBeam")) == 0
def test_removing_all_containment_relationships_of_a_container(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace")
total_entities = len(list(self.file))
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
assert len(self.file.by_type("IfcSpace")) == 0
assert len(self.file.by_type("IfcWall")) == 1
def test_removing_all_containment_relationships_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace")
total_entities = len(list(self.file))
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.root.remove_product(self.file, product=subelement)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
assert len(self.file.by_type("IfcSpace")) == 1
assert len(self.file.by_type("IfcWall")) == 0
def test_removing_path_connection_relationships_of_an_element(self):
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcColumn")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcColumn")
total_entities = len(list(self.file))
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=element1, related_element=element2)
- ifcopenshell.api.run("root.remove_product", self.file, product=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ ifcopenshell.api.geometry.connect_path(self.file, relating_element=element1, related_element=element2)
+ ifcopenshell.api.root.remove_product(self.file, product=element1)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 0
assert len(self.file.by_type("IfcColumn")) == 1
assert len(self.file.by_type("IfcBeam")) == 0
def test_removing_connection_relationships_of_an_element(self):
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
total_entities = len(list(self.file))
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "geometry.connect_element",
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.connect_element(
self.file,
related_element=element1,
relating_element=element2,
)
- ifcopenshell.api.run("root.remove_product", self.file, product=element1)
+ ifcopenshell.api.root.remove_product(self.file, product=element1)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
assert len(self.file.by_type("IfcSlab")) == 1
assert len(self.file.by_type("IfcWall")) == 0
def test_removing_connection_relationships_of_an_element_with_additional_realizing_element(self):
- slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
total_entities = len(list(self.file))
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
self.file.createIfcRelConnectsWithRealizingElements(
ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingElement=wall,
RelatedElement=slab1,
RealizingElements=(wall, slab1, slab2),
)
- ifcopenshell.api.run("root.remove_product", self.file, product=wall)
+ ifcopenshell.api.root.remove_product(self.file, product=wall)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
assert len(self.file.by_type("IfcSlab")) == 2
assert len(self.file.by_type("IfcWall")) == 0
def test_removing_connection_relationships_of_an_element_element_is_realizing_element(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
total_entities = len(list(self.file))
- slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
slab2_entities = len(list(self.file)) - total_entities
self.file.createIfcRelConnectsWithRealizingElements(
ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingElement=wall,
RelatedElement=slab1,
RealizingElements=(wall, slab1, slab2),
)
total_entities = len(list(self.file))
- ifcopenshell.api.run("root.remove_product", self.file, product=slab2)
+ ifcopenshell.api.root.remove_product(self.file, product=slab2)
assert len(list(self.file)) == (total_entities - slab2_entities)
assert len(self.file.by_type("IfcRelConnectsElements")) == 1
assert len(self.file.by_type("IfcSlab")) == 1
assert len(self.file.by_type("IfcWall")) == 1
def test_removing_connection_relationships_of_an_element_element_is_only_realizing_element(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
total_entities = len(list(self.file))
- slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
self.file.createIfcRelConnectsWithRealizingElements(
ifcopenshell.guid.new(),
- OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
+ OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
RelatingElement=wall,
RelatedElement=slab1,
RealizingElements=(slab2,),
)
- ifcopenshell.api.run("root.remove_product", self.file, product=slab2)
+ ifcopenshell.api.root.remove_product(self.file, product=slab2)
assert len(list(self.file)) == total_entities
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
assert len(self.file.by_type("IfcSlab")) == 1
assert len(self.file.by_type("IfcWall")) == 1
def test_removing_ports_connection_relationship(self):
- port1 = ifcopenshell.api.run("system.add_port", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element1, port=port1)
+ port1 = ifcopenshell.api.system.add_port(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element1, port=port1)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SOURCE")
+ ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SOURCE")
connection = self.file.by_type("IfcRelConnectsPorts")[0]
# making sure removing realizing element won't remove the entire connection since it's optional
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
connection.RealizingElement = element3
- ifcopenshell.api.run("root.remove_product", self.file, product=element3)
+ ifcopenshell.api.root.remove_product(self.file, product=element3)
assert len(self.file.by_type("IfcRelConnectsPorts")) == 1
- ifcopenshell.api.run("root.remove_product", self.file, product=element1)
+ ifcopenshell.api.root.remove_product(self.file, product=element1)
assert len(self.file.by_type("IfcRelConnectsPorts")) == 0
assert len(self.file.by_type("IfcFlowSegment")) == 1
assert len(self.file.by_type("IfcDistributionPort")) == 1
def test_removing_all_property_relationships_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelDefinesByProperties")
assert not self.file.by_type("IfcPropertySet")
assert not self.file.by_type("IfcPropertySingleValue")
def test_removing_all_material_relationships_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="Foo")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="Foo")
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelAssociatesMaterial")
assert self.file.by_type("IfcMaterial")
def test_removing_all_type_relationships_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelDefinesByType")
assert self.file.by_type("IfcWallType")
def test_removing_all_type_relationships_of_an_element_type(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
- ifcopenshell.api.run("root.remove_product", self.file, product=element_type)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
+ ifcopenshell.api.root.remove_product(self.file, product=element_type)
assert not self.file.by_type("IfcRelDefinesByType")
assert self.file.by_type("IfcWall")
def test_removing_all_space_boundaries_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
boundary = self.file.createIfcRelSpaceBoundary(GlobalId=ifcopenshell.guid.new(), RelatedBuildingElement=element)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelSpaceBoundary")
def test_removing_orphaned_group_relationships(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file, name="Unit 1A")
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file, name="Unit 1A")
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelAssignsToGroup")
def test_removing_product_assignments(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- annotation = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcAnnotation")
- ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=element, related_object=annotation)
- ifcopenshell.api.run("root.remove_product", self.file, product=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ annotation = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcAnnotation")
+ ifcopenshell.api.drawing.assign_product(self.file, relating_product=element, related_object=annotation)
+ ifcopenshell.api.root.remove_product(self.file, product=element)
assert not self.file.by_type("IfcRelAssignsToProduct")
def test_removing_flow_control_elements(self):
- flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
- flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
+ flow_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ flow_control = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
+ flow_control1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
- ifcopenshell.api.run(
- "system.assign_flow_control",
- self.file,
- related_flow_control=flow_control,
- relating_flow_element=flow_element,
+ ifcopenshell.api.system.assign_flow_control(
+ self.file, related_flow_control=flow_control, relating_flow_element=flow_element
)
- ifcopenshell.api.run(
- "system.assign_flow_control",
- self.file,
- related_flow_control=flow_control1,
- relating_flow_element=flow_element,
+ ifcopenshell.api.system.assign_flow_control(
+ self.file, related_flow_control=flow_control1, relating_flow_element=flow_element
)
- ifcopenshell.api.run("root.remove_product", self.file, product=flow_control)
+ ifcopenshell.api.root.remove_product(self.file, product=flow_control)
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
- ifcopenshell.api.run("root.remove_product", self.file, product=flow_control1)
+ ifcopenshell.api.root.remove_product(self.file, product=flow_control1)
assert not self.file.by_type("IfcRelFlowControlElements")
def test_removing_flow_element_with_flow_controls(self):
- flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
- flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
+ flow_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ flow_control = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
+ flow_control1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
- ifcopenshell.api.run(
- "system.assign_flow_control",
- self.file,
- related_flow_control=flow_control,
- relating_flow_element=flow_element,
+ ifcopenshell.api.system.assign_flow_control(
+ self.file, related_flow_control=flow_control, relating_flow_element=flow_element
)
- ifcopenshell.api.run(
- "system.assign_flow_control",
- self.file,
- related_flow_control=flow_control1,
- relating_flow_element=flow_element,
+ ifcopenshell.api.system.assign_flow_control(
+ self.file, related_flow_control=flow_control1, relating_flow_element=flow_element
)
- ifcopenshell.api.run("root.remove_product", self.file, product=flow_element)
+ ifcopenshell.api.root.remove_product(self.file, product=flow_element)
assert not self.file.by_type("IfcRelFlowControlElements")
diff --git a/src/ifcopenshell-python/test/api/sequence/test_assign_product.py b/src/ifcopenshell-python/test/api/sequence/test_assign_product.py
index f0973e2fd0..19812e820c 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_assign_product.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_assign_product.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.sequence
class TestAssignProduct(test.bootstrap.IFC4):
@@ -25,16 +25,16 @@ class TestAssignProduct(test.bootstrap.IFC4):
wall = self.file.createIfcWall()
task = self.file.createIfcTask()
task2 = self.file.createIfcTask()
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=wall, related_object=task)
assert wall.ReferencedBy[0].RelatedObjects == (task,)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task2)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=wall, related_object=task2)
assert wall.ReferencedBy[0].RelatedObjects == (task, task2)
def test_not_assigning_twice(self):
wall = self.file.createIfcWall()
task = self.file.createIfcTask()
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=wall, related_object=task)
assert wall.ReferencedBy[0].RelatedObjects == (task,)
diff --git a/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py b/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py
index 06f0ed367b..daed2ecb64 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py
@@ -17,74 +17,77 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.pset
+import ifcopenshell.api.sequence
+import ifcopenshell.api.resource
# NOTE: sequence module features relies on entities introduced in IFC4
# therefore no IFC2X3 tests
class TestCalculateTaskDuration(test.bootstrap.IFC4):
def test_calculating_the_duration_based_on_a_labour_resource_with_work_hours(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- resource_time = ifcopenshell.api.run("resource.add_resource_time", self.file, resource=resource)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ resource_time = ifcopenshell.api.resource.add_resource_time(self.file, resource=resource)
resource_time.ScheduleWork = "PT48H"
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
assert task.TaskTime.ScheduleDuration == "P6D"
def test_calculating_the_duration_based_on_a_labour_resource_with_work_days(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- resource_time = ifcopenshell.api.run("resource.add_resource_time", self.file, resource=resource)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ resource_time = ifcopenshell.api.resource.add_resource_time(self.file, resource=resource)
resource_time.ScheduleWork = "P3.5D"
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
assert task.TaskTime.ScheduleDuration == "P4D"
def test_calculating_a_task_duration_without_a_work_schedule_defining_workday_duration(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- resource_time = ifcopenshell.api.run("resource.add_resource_time", self.file, resource=resource)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ resource_time = ifcopenshell.api.resource.add_resource_time(self.file, resource=resource)
resource_time.ScheduleWork = "P2D"
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
assert task.TaskTime.ScheduleDuration == "P2D"
def test_calculating_a_task_duration_with_a_custom_workday_duration(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=schedule, name="Pset_WorkControlCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"WorkDayDuration": "PT2H"})
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- resource_time = ifcopenshell.api.run("resource.add_resource_time", self.file, resource=resource)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=schedule, name="Pset_WorkControlCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"WorkDayDuration": "PT2H"})
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ resource_time = ifcopenshell.api.resource.add_resource_time(self.file, resource=resource)
resource_time.ScheduleWork = "PT48H"
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
assert task.TaskTime.ScheduleDuration == "P24D"
def test_failing_to_calculate_if_no_schedule_work_usage(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=task)
assert task.TaskTime is None
def test_calculating_a_nested_task_duration_based_on_a_labour_resource_with_work_hours(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
- subtask = ifcopenshell.api.run("sequence.add_task", self.file, parent_task=task)
- resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
- resource_time = ifcopenshell.api.run("resource.add_resource_time", self.file, resource=resource)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
+ subtask = ifcopenshell.api.sequence.add_task(self.file, parent_task=task)
+ resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
+ resource_time = ifcopenshell.api.resource.add_resource_time(self.file, resource=resource)
resource_time.ScheduleWork = "PT48H"
- ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=subtask, related_object=resource)
- ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=subtask)
+ ifcopenshell.api.sequence.assign_process(self.file, relating_process=subtask, related_object=resource)
+ ifcopenshell.api.sequence.calculate_task_duration(self.file, task=subtask)
assert subtask.TaskTime.ScheduleDuration == "P6D"
diff --git a/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py b/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py
index dd921ec2ae..87d5647343 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py
@@ -19,22 +19,22 @@
import pytest
import datetime
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.sequence
# NOTE: sequence module features relies on entities introduced in IFC4
# therefore no IFC2X3 tests
class TestCascadeSchedule(test.bootstrap.IFC4):
def test_doing_nothing_if_the_task_has_no_successors(self):
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime is None
def test_not_affecting_tasks_that_are_not_related(self):
task = self._create_task("P1D")
task2 = self._create_task("P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
@@ -47,7 +47,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task2)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task2)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
@@ -62,7 +62,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "FINISH_START")
with pytest.raises(RecursionError):
self._create_sequence(task2, task, "FINISH_START")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
def test_cascading_finish_to_start(self):
task = self._create_task("P1D")
@@ -71,7 +71,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "2000-01-02T09:00:00"
@@ -86,7 +86,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T09:00:00"
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
@@ -101,7 +101,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "FINISH_FINISH")
self._create_sequence(task, task3, "FINISH_FINISH", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "1999-12-31T09:00:00"
@@ -116,7 +116,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "START_START")
self._create_sequence(task, task3, "START_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
@@ -131,7 +131,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "START_FINISH")
self._create_sequence(task, task3, "START_FINISH", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task2.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
@@ -146,7 +146,7 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
self._create_sequence(task, task2, "START_FINISH")
self._create_sequence(task, task3, "START_FINISH", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T09:00:00"
assert task2.TaskTime.ScheduleStart == "1999-12-30T09:00:00"
@@ -155,12 +155,11 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
assert task3.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
def _create_task(self, duration):
- task = ifcopenshell.api.run("sequence.add_task", self.file)
+ task = ifcopenshell.api.sequence.add_task(self.file)
if duration == "P0D":
task.IsMilestone = True
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=task)
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={"ScheduleStart": datetime.date(2000, 1, 1), "ScheduleDuration": duration},
@@ -168,13 +167,11 @@ class TestCascadeSchedule(test.bootstrap.IFC4):
return task
def _create_sequence(self, predecessor, successor, relationship, lag=None):
- rel = ifcopenshell.api.run(
- "sequence.assign_sequence", self.file, relating_process=predecessor, related_process=successor
- )
- ifcopenshell.api.run(
- "sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": relationship}
+ rel = ifcopenshell.api.sequence.assign_sequence(
+ self.file, relating_process=predecessor, related_process=successor
)
+ ifcopenshell.api.sequence.edit_sequence(self.file, rel_sequence=rel, attributes={"SequenceType": relationship})
if lag:
- ifcopenshell.api.run(
- "sequence.assign_lag_time", self.file, rel_sequence=rel, lag_value=lag, duration_type="WORKTIME"
+ ifcopenshell.api.sequence.assign_lag_time(
+ self.file, rel_sequence=rel, lag_value=lag, duration_type="WORKTIME"
)
diff --git a/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py
index efd41b0176..b4e138f16b 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py
@@ -18,7 +18,9 @@
import datetime
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.control
+import ifcopenshell.api.sequence
# NOTE: IfcTaskTime was introduced in IFC4
@@ -26,9 +28,8 @@ import ifcopenshell.api
class TestEditTaskTime(test.bootstrap.IFC4):
def test_editing_all_attributes(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -76,9 +77,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.Completion == 0.5
def test_editing_just_a_start_date_with_no_duration_or_finish(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -92,13 +92,12 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleDuration is None
def test_editing_just_a_start_date_with_no_duration_or_finish_but_with_a_calendar(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ calendar = ifcopenshell.api.sequence.add_work_calendar(self.file)
task = self.file.createIfcTask()
- ifcopenshell.api.run("control.assign_control", self.file, relating_control=calendar, related_object=task)
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ ifcopenshell.api.control.assign_control(self.file, relating_control=calendar, related_object=task)
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=task)
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -112,9 +111,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleDuration is None
def test_schedule_finish_dates_are_auto_calculated_if_possible(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -129,9 +127,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
def test_schedule_durations_are_auto_calculated_if_possible(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -146,9 +143,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
def test_a_duration_takes_priority_over_start_and_finish_dates(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -164,9 +160,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
def test_durations_can_be_specified_in_datetime_objects(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -181,9 +176,8 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2000-01-01T17:00:00"
def test_zero_durations_are_allowed(self):
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=self.file.createIfcTask())
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -198,13 +192,12 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2000-01-01T09:00:00"
def test_editing_a_start_date_and_duration_with_a_calendar(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- calendar = ifcopenshell.api.run("sequence.add_work_calendar", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ calendar = ifcopenshell.api.sequence.add_work_calendar(self.file)
task = self.file.createIfcTask()
- ifcopenshell.api.run("control.assign_control", self.file, relating_control=calendar, related_object=task)
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ ifcopenshell.api.control.assign_control(self.file, relating_control=calendar, related_object=task)
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=task)
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
@@ -217,23 +210,19 @@ class TestEditTaskTime(test.bootstrap.IFC4):
assert task_time.ScheduleFinish == "2020-01-07T17:00:00"
assert task_time.ScheduleDuration == "P7D"
- work_time = ifcopenshell.api.run(
- "sequence.add_work_time", self.file, work_calendar=calendar, time_type="WorkingTimes"
+ work_time = ifcopenshell.api.sequence.add_work_time(self.file, work_calendar=calendar, time_type="WorkingTimes")
+ pattern = ifcopenshell.api.sequence.assign_recurrence_pattern(
+ self.file, parent=work_time, recurrence_type="WEEKLY"
)
- pattern = ifcopenshell.api.run(
- "sequence.assign_recurrence_pattern", self.file, parent=work_time, recurrence_type="WEEKLY"
- )
- ifcopenshell.api.run(
- "sequence.edit_recurrence_pattern",
+ ifcopenshell.api.sequence.edit_recurrence_pattern(
self.file,
recurrence_pattern=pattern,
attributes={"WeekdayComponent": [1, 2, 3, 4, 5]},
)
- ifcopenshell.api.run(
- "sequence.add_time_period", self.file, recurrence_pattern=pattern, start_time="09:00", end_time="17:00"
+ ifcopenshell.api.sequence.add_time_period(
+ self.file, recurrence_pattern=pattern, start_time="09:00", end_time="17:00"
)
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={
diff --git a/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py b/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py
index ce024a1bca..dc58088d38 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py
@@ -18,7 +18,7 @@
import datetime
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.sequence
# NOTE: IfcWorkTime was introduced in IFC4
@@ -34,7 +34,7 @@ class TestEditWorkTime(test.bootstrap.IFC4):
"Start": datetime.datetime(2020, 1, 1),
"Finish": datetime.datetime(2020, 2, 1),
}
- ifcopenshell.api.run("sequence.edit_work_time", self.file, work_time=work_time, attributes=attributes)
+ ifcopenshell.api.sequence.edit_work_time(self.file, work_time=work_time, attributes=attributes)
assert work_time.Name == attributes["Name"]
assert work_time.DataOrigin == attributes["DataOrigin"]
assert work_time.UserDefinedDataOrigin == attributes["UserDefinedDataOrigin"]
@@ -55,7 +55,7 @@ class TestEditWorkTimeIFC4X3(test.bootstrap.IFC4X3):
"StartDate": datetime.datetime(2020, 1, 1),
"FinishDate": datetime.datetime(2020, 2, 1),
}
- ifcopenshell.api.run("sequence.edit_work_time", self.file, work_time=work_time, attributes=attributes)
+ ifcopenshell.api.sequence.edit_work_time(self.file, work_time=work_time, attributes=attributes)
assert work_time.Name == attributes["Name"]
assert work_time.DataOrigin == attributes["DataOrigin"]
assert work_time.UserDefinedDataOrigin == attributes["UserDefinedDataOrigin"]
diff --git a/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py b/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py
index b08c38273c..d5aacde632 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py
@@ -19,7 +19,8 @@
import pytest
import datetime
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.sequence
# NOTE: sequence module features relies on entities introduced in IFC4
@@ -28,8 +29,8 @@ import ifcopenshell.api
class TestRecalculateSchedule(test.bootstrap.IFC4):
def test_doing_nothing_if_the_task_has_no_time(self):
self._add_work_schedule()
- task = ifcopenshell.api.run("sequence.add_task", self.file)
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ task = ifcopenshell.api.sequence.add_task(self.file)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime is None
def test_catching_cyclic_relationships(self):
@@ -44,12 +45,12 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
with pytest.raises(RecursionError):
self._create_sequence(task3, task2, "FINISH_START")
with pytest.raises(RecursionError):
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
def test_recalculating_for_a_single_task(self):
self._add_work_schedule()
task = self._create_task("P1D")
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -65,7 +66,7 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task = self._create_task("P1D")
task2 = self._create_task("P2D")
self._create_sequence(task, task2, "FINISH_START")
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -92,8 +93,8 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task3 = self._create_task("P3D")
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -129,8 +130,8 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task3 = self._create_task("P0D")
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task, task3, "FINISH_START", lag="P1D")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -166,8 +167,8 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task3 = self._create_task("P0D")
self._create_sequence(task, task2, "FINISH_START")
self._create_sequence(task2, task3, "FINISH_START")
- ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.cascade_schedule(self.file, task=task)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -201,7 +202,7 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task = self._create_task("P1D")
task2 = self._create_task("P2D")
self._create_sequence(task, task2, "FINISH_FINISH")
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -226,7 +227,7 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task = self._create_task("P1D")
task2 = self._create_task("P2D")
self._create_sequence(task, task2, "START_START")
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -251,7 +252,7 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
task = self._create_task("P1D")
task2 = self._create_task("P2D")
self._create_sequence(task, task2, "START_FINISH")
- ifcopenshell.api.run("sequence.recalculate_schedule", self.file, work_schedule=self.work_schedule)
+ ifcopenshell.api.sequence.recalculate_schedule(self.file, work_schedule=self.work_schedule)
assert task.TaskTime.ScheduleStart == "2000-01-01T09:00:00"
assert task.TaskTime.ScheduleFinish == "2000-01-01T17:00:00"
assert task.TaskTime.EarlyStart == "2000-01-01T09:00:00"
@@ -272,16 +273,15 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
assert task2.TaskTime.IsCritical is True
def _add_work_schedule(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- self.work_schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ self.work_schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
def _create_task(self, duration):
- task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=self.work_schedule)
+ task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=self.work_schedule)
if duration == "P0D":
task.IsMilestone = True
- task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
- ifcopenshell.api.run(
- "sequence.edit_task_time",
+ task_time = ifcopenshell.api.sequence.add_task_time(self.file, task=task)
+ ifcopenshell.api.sequence.edit_task_time(
self.file,
task_time=task_time,
attributes={"ScheduleStart": datetime.date(2000, 1, 1), "ScheduleDuration": duration},
@@ -289,13 +289,11 @@ class TestRecalculateSchedule(test.bootstrap.IFC4):
return task
def _create_sequence(self, predecessor, successor, relationship, lag=None):
- rel = ifcopenshell.api.run(
- "sequence.assign_sequence", self.file, relating_process=predecessor, related_process=successor
- )
- ifcopenshell.api.run(
- "sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": relationship}
+ rel = ifcopenshell.api.sequence.assign_sequence(
+ self.file, relating_process=predecessor, related_process=successor
)
+ ifcopenshell.api.sequence.edit_sequence(self.file, rel_sequence=rel, attributes={"SequenceType": relationship})
if lag:
- ifcopenshell.api.run(
- "sequence.assign_lag_time", self.file, rel_sequence=rel, lag_value=lag, duration_type="WORKTIME"
+ ifcopenshell.api.sequence.assign_lag_time(
+ self.file, rel_sequence=rel, lag_value=lag, duration_type="WORKTIME"
)
diff --git a/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py b/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py
index 4dba192ef3..fdeae7e25d 100644
--- a/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py
+++ b/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.sequence
class TestUnassignProduct(test.bootstrap.IFC4):
def test_unassigning_a_product(self):
wall = self.file.createIfcWall()
task = self.file.createIfcTask()
- ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
- ifcopenshell.api.run("sequence.unassign_product", self.file, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.assign_product(self.file, relating_product=wall, related_object=task)
+ ifcopenshell.api.sequence.unassign_product(self.file, relating_product=wall, related_object=task)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
diff --git a/src/ifcopenshell-python/test/api/spatial/test_assign_container.py b/src/ifcopenshell-python/test/api/spatial/test_assign_container.py
index e4ca971319..e4dc44eef5 100644
--- a/src/ifcopenshell-python/test/api/spatial/test_assign_container.py
+++ b/src/ifcopenshell-python/test/api/spatial/test_assign_container.py
@@ -19,60 +19,64 @@
import numpy
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.unit
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
import ifcopenshell.util.element
import ifcopenshell.util.placement
class TestAssignContainer(test.bootstrap.IFC4):
def test_assigning_a_container(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "spatial.assign_container", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.spatial.assign_container(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
assert ifcopenshell.util.element.get_container(subelement) == element
assert ifcopenshell.util.element.get_container(subelement2) == element
assert rel.is_a("IfcRelContainedInSpatialStructure")
def test_doing_nothing_if_the_container_is_already_assigned(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
assert len([e for e in self.file]) == total_elements
def test_that_old_containment_relationships_are_updated_if_they_still_contain_elements(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement1], relating_structure=element1)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement2], relating_structure=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement1], relating_structure=element1)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement2], relating_structure=element1)
rel = subelement1.ContainedInStructure[0]
assert len(rel.RelatedElements) == 2
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement1], relating_structure=element2)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement1], relating_structure=element2)
assert len(rel.RelatedElements) == 1
def test_that_old_containment_relationships_are_purged_if_no_more_elements_are_contained(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement1], relating_structure=element1)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement1], relating_structure=element1)
rel_id = subelement1.ContainedInStructure[0].id()
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement1], relating_structure=element2)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement1], relating_structure=element2)
with pytest.raises(RuntimeError):
self.file.by_id(rel_id)
def test_assigning_a_container_does_not_shift_object_placements(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element1)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element1)
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -89,37 +93,37 @@ class TestAssignContainer(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element1, matrix=matrix1.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element1, matrix=matrix1.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element2, matrix=matrix2.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element2, matrix=matrix2.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=matrix1.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=matrix1.copy(), is_si=False
)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element2)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element2)
assert subelement.ObjectPlacement.PlacementRelTo.PlacesObject[0] == element2
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), matrix1)
def test_not_updating_placement_if_placement_is_not_relative(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
placement = self.file.createIfcGridPlacement()
subelement.ObjectPlacement = placement
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
assert subelement.ObjectPlacement == placement
def test_removing_aggregation_if_it_exists(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- aggregate = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=aggregate)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ aggregate = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=aggregate)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
assert not ifcopenshell.util.element.get_aggregate(subelement)
diff --git a/src/ifcopenshell-python/test/api/spatial/test_dereference_structure.py b/src/ifcopenshell-python/test/api/spatial/test_dereference_structure.py
index 474f8bbcaf..ccec00e697 100644
--- a/src/ifcopenshell-python/test/api/spatial/test_dereference_structure.py
+++ b/src/ifcopenshell-python/test/api/spatial/test_dereference_structure.py
@@ -16,49 +16,49 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.spatial
import ifcopenshell.util.element
class TestDereferenceStructure(test.bootstrap.IFC4):
def test_removing_a_container(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
- ifcopenshell.api.run(
- "spatial.dereference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ ifcopenshell.api.spatial.dereference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
assert ifcopenshell.util.element.get_referenced_structures(subelement) == []
assert len(self.file.by_type("IfcRelReferencedInSpatialStructure")) == 0
def test_doing_nothing_if_no_container(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.dereference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.dereference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
assert ifcopenshell.util.element.get_referenced_structures(subelement) == []
assert ifcopenshell.util.element.get_referenced_structures(subelement2) == []
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement1], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement1], relating_structure=element
)
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement2, subelement3], relating_structure=element
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement2, subelement3], relating_structure=element
)
- ifcopenshell.api.run(
- "spatial.dereference_structure", self.file, products=[subelement1, subelement2], relating_structure=element
+ ifcopenshell.api.spatial.dereference_structure(
+ self.file, products=[subelement1, subelement2], relating_structure=element
)
assert element.ReferencesElements[0].RelatedElements == (subelement3,)
diff --git a/src/ifcopenshell-python/test/api/spatial/test_reference_structure.py b/src/ifcopenshell-python/test/api/spatial/test_reference_structure.py
index 0ef22d708a..013b0e4a18 100644
--- a/src/ifcopenshell-python/test/api/spatial/test_reference_structure.py
+++ b/src/ifcopenshell-python/test/api/spatial/test_reference_structure.py
@@ -16,45 +16,43 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.spatial
import ifcopenshell.util.element
class TestReferenceStructure(test.bootstrap.IFC4):
def test_referencing_a_structure(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
assert ifcopenshell.util.element.get_structure_referenced_elements(element) == {subelement, subelement2}
def test_doing_nothing_if_the_structure_is_already_referenced(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement, subelement2], relating_structure=element
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
assert len([e for e in self.file]) == total_elements
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement1], relating_structure=element
- )
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.reference_structure", self.file, products=[subelement2, subelement3], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(self.file, products=[subelement1], relating_structure=element)
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(
+ self.file, products=[subelement2, subelement3], relating_structure=element
)
rel = subelement1.ReferencedInStructures[0]
assert len(rel.RelatedElements) == 3
diff --git a/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py b/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py
index d7f172817c..795614e35d 100644
--- a/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py
+++ b/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py
@@ -16,46 +16,45 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.spatial
import ifcopenshell.util.element
import ifcopenshell.util.placement
class TestUnassignContainer(test.bootstrap.IFC4):
def test_unassigning_a_container(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.assign_container", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
- ifcopenshell.api.run("spatial.unassign_container", self.file, products=[subelement, subelement2])
+ ifcopenshell.api.spatial.unassign_container(self.file, products=[subelement, subelement2])
assert not self.file.by_type("IfcRelContainedInSpatialStructure")
def test_doing_nothing_if_no_container(self):
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.unassign_container", self.file, products=[subelement])
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.unassign_container(self.file, products=[subelement])
assert ifcopenshell.util.element.get_container(subelement) is None
def test_updating_the_rel_when_a_container_is_removed_with_multipled_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "spatial.assign_container", self.file, products=[subelement, subelement2], relating_structure=element
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(
+ self.file, products=[subelement, subelement2], relating_structure=element
)
- ifcopenshell.api.run("spatial.unassign_container", self.file, products=[subelement])
+ ifcopenshell.api.spatial.unassign_container(self.file, products=[subelement])
rel = self.file.by_type("IfcRelContainedInSpatialStructure")[0]
assert list(rel.RelatedElements) == [subelement2]
def test_deleting_the_rel_when_a_container_is_removed_with_no_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
- ifcopenshell.api.run("spatial.unassign_container", self.file, products=[subelement])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
+ ifcopenshell.api.spatial.unassign_container(self.file, products=[subelement])
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
diff --git a/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py
index 9fb407530d..c7c715d1c0 100644
--- a/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py
+++ b/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py
@@ -16,15 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.structural
class TestAddStructuralAnalysisModel(test.bootstrap.IFC4):
def test_adding_a_structural_analysis_model(self):
- subject = ifcopenshell.api.run("structural.add_structural_analysis_model", self.file)
+ subject = ifcopenshell.api.structural.add_structural_analysis_model(self.file)
models = self.file.by_type("IfcStructuralAnalysisModel")
assert subject == models[0]
assert subject.is_a("IfcStructuralAnalysisModel")
diff --git a/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py
index 7146a53f59..4e8cbb0f00 100644
--- a/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py
+++ b/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py
@@ -16,20 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.structural
class TestAssignStructuralAnalysisModel(test.bootstrap.IFC4):
def test_assigning_a_structural_analysis_model(self):
- subject = ifcopenshell.api.run("structural.add_structural_analysis_model", self.file)
- product = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcStructuralMember", predefined_type=None, name=None
+ subject = ifcopenshell.api.structural.add_structural_analysis_model(self.file)
+ product = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcStructuralMember", predefined_type=None, name=None
)
- rel = ifcopenshell.api.run(
- "structural.assign_structural_analysis_model",
+ rel = ifcopenshell.api.structural.assign_structural_analysis_model(
self.file,
product=product,
structural_analysis_model=subject,
diff --git a/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py
index 4527a0d3d8..18f389f488 100644
--- a/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py
+++ b/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py
@@ -16,17 +16,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.structural
class TestEditStructuralAnalysisModel(test.bootstrap.IFC4):
def test_editing_a_structural_analysis_model(self):
- subject = ifcopenshell.api.run("structural.add_structural_analysis_model", self.file)
- subject = ifcopenshell.api.run(
- "structural.edit_structural_analysis_model",
+ subject = ifcopenshell.api.structural.add_structural_analysis_model(self.file)
+ subject = ifcopenshell.api.structural.edit_structural_analysis_model(
self.file,
structural_analysis_model=subject,
attributes={"Name": "My edited model", "Description": "Description of my model"},
diff --git a/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py
index a631d741aa..b496dcc9a1 100644
--- a/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py
+++ b/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py
@@ -16,17 +16,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.structural
class TestRemoveStructuralAnalysisModel(test.bootstrap.IFC4):
def test_removing_a_structural_analysis_model(self):
- subject = ifcopenshell.api.run("structural.add_structural_analysis_model", self.file)
- ifcopenshell.api.run(
- "structural.remove_structural_analysis_model",
+ subject = ifcopenshell.api.structural.add_structural_analysis_model(self.file)
+ ifcopenshell.api.structural.remove_structural_analysis_model(
self.file,
structural_analysis_model=subject,
)
diff --git a/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py
index b2269b8a3a..e43fe1eaa0 100644
--- a/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py
+++ b/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py
@@ -16,26 +16,23 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import numpy
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.structural
class TestUnassignStructuralAnalysisModel(test.bootstrap.IFC4):
def test_unassigning_a_structural_analysis_model(self):
- subject = ifcopenshell.api.run("structural.add_structural_analysis_model", self.file)
- product = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcStructuralMember", predefined_type=None, name=None
+ subject = ifcopenshell.api.structural.add_structural_analysis_model(self.file)
+ product = ifcopenshell.api.root.create_entity(
+ self.file, ifc_class="IfcStructuralMember", predefined_type=None, name=None
)
- rel = ifcopenshell.api.run(
- "structural.assign_structural_analysis_model",
+ ifcopenshell.api.structural.assign_structural_analysis_model(
self.file,
product=product,
structural_analysis_model=subject,
)
- ifcopenshell.api.run(
- "structural.unassign_structural_analysis_model",
+ ifcopenshell.api.structural.unassign_structural_analysis_model(
self.file,
product=product,
structural_analysis_model=subject,
diff --git a/src/ifcopenshell-python/test/api/style/test_add_surface_style.py b/src/ifcopenshell-python/test/api/style/test_add_surface_style.py
index 80e297bed0..83f176a690 100644
--- a/src/ifcopenshell-python/test/api/style/test_add_surface_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_add_surface_style.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.style
class TestAddSurfaceStyle(test.bootstrap.IFC4):
@@ -27,8 +26,7 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- result = ifcopenshell.api.run(
- "style.add_surface_style",
+ result = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleShading",
@@ -47,8 +45,7 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- result = ifcopenshell.api.run(
- "style.add_surface_style",
+ result = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleRendering",
@@ -67,15 +64,13 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- ifcopenshell.api.run(
- "style.add_surface_style",
+ ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleRendering",
attributes=attrs,
)
- result = ifcopenshell.api.run(
- "style.add_surface_style",
+ result = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleRendering",
@@ -89,15 +84,13 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- result1 = ifcopenshell.api.run(
- "style.add_surface_style",
+ result1 = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleShading",
attributes=attrs,
)
- result2 = ifcopenshell.api.run(
- "style.add_surface_style",
+ result2 = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleWithTextures",
@@ -112,15 +105,13 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- ifcopenshell.api.run(
- "style.add_surface_style",
+ ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleShading",
attributes=attrs,
)
- result = ifcopenshell.api.run(
- "style.add_surface_style",
+ result = ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleRendering",
diff --git a/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py b/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py
index 590aa02399..78971148d7 100644
--- a/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py
+++ b/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py
@@ -18,7 +18,7 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.style
# TODO: add ifc2x3 tests after add_surface_textures will support ifc2x3
@@ -51,7 +51,7 @@ class TestAddSurfaceTexture(test.bootstrap.IFC4):
def test_add_surface_textures_from_data(self):
texture_data = self.get_default_texture_data()
- textures = ifcopenshell.api.run("style.add_surface_textures", self.file, textures=texture_data)
+ textures = ifcopenshell.api.style.add_surface_textures(self.file, textures=texture_data)
assert len(list(self.file)) == len(texture_data)
for texture, data in zip(textures, texture_data):
@@ -64,7 +64,7 @@ class TestAddSurfaceTexture(test.bootstrap.IFC4):
texture_data[2]["uv_mode"] = "UV"
texture_data[3]["uv_mode"] = None
- textures = ifcopenshell.api.run("style.add_surface_textures", self.file, textures=texture_data)
+ textures = ifcopenshell.api.style.add_surface_textures(self.file, textures=texture_data)
for texture, data in zip(textures, texture_data):
self.compare_texture_to_data(texture, data)
@@ -77,6 +77,6 @@ class TestAddSurfaceTexture(test.bootstrap.IFC4):
texture_data[3]["uv_mode"] = None
uv_maps = [self.file.create_entity("IfcTextureCoordinateGenerator", Maps=[], Mode="COORD") for i in range(5)]
- textures = ifcopenshell.api.run("style.add_surface_textures", self.file, textures=texture_data, uv_maps=uv_maps)
+ textures = ifcopenshell.api.style.add_surface_textures(self.file, textures=texture_data, uv_maps=uv_maps)
for texture, data in zip(textures, texture_data):
self.compare_texture_to_data(texture, data, uv_maps)
diff --git a/src/ifcopenshell-python/test/api/style/test_assign_material_style.py b/src/ifcopenshell-python/test/api/style/test_assign_material_style.py
index 14bdf5fda9..ee18811a32 100644
--- a/src/ifcopenshell-python/test/api/style/test_assign_material_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_assign_material_style.py
@@ -16,18 +16,19 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.style
+import ifcopenshell.api.material
class TestAssignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
def test_run(self):
- material = ifcopenshell.api.run("material.add_material", self.file)
+ material = ifcopenshell.api.material.add_material(self.file)
context = self.file.createIfcGeometricRepresentationContext()
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
assert len(material.HasRepresentation) == 1
definition = material.HasRepresentation[0]
@@ -46,7 +47,7 @@ class TestAssignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
assert item.Styles[0].Styles == (style,)
style2 = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style2, context=context)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style2, context=context)
# reuse existing elements and reassign the style
assert material.HasRepresentation == (definition,)
@@ -66,7 +67,7 @@ class TestAssignMaterialStyleIFC4(test.bootstrap.IFC4, TestAssignMaterialStyleIF
def test_update_shape_aspect_representations_items_styles_if_material_is_part_of_matching_material_constituents(
self,
):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
name = "Concrete"
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -80,16 +81,16 @@ class TestAssignMaterialStyleIFC4(test.bootstrap.IFC4, TestAssignMaterialStyleIF
shape_aspect.PartOfProductDefinitionShape = product_shape
style = self.file.createIfcSurfaceStyle()
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, set_type="IfcMaterialConstituentSet"
)
- constituent = ifcopenshell.api.run(
- "material.add_constituent", self.file, constituent_set=material_set, material=material
+ constituent = ifcopenshell.api.material.add_constituent(
+ self.file, constituent_set=material_set, material=material
)
constituent.Name = name
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
assert item.StyledByItem[0].Styles == (style,)
diff --git a/src/ifcopenshell-python/test/api/style/test_assign_representation_styles.py b/src/ifcopenshell-python/test/api/style/test_assign_representation_styles.py
index c08a61952e..1995417e31 100644
--- a/src/ifcopenshell-python/test/api/style/test_assign_representation_styles.py
+++ b/src/ifcopenshell-python/test/api/style/test_assign_representation_styles.py
@@ -16,15 +16,15 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.style
class TestAssignRepresentationStyles(test.bootstrap.IFC4):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -33,29 +33,29 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
representation.Items = [item]
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, styles=[style], shape_representation=representation
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, styles=[style], shape_representation=representation
)
assert item.StyledByItem[0].Styles == (style,)
# reusing existing styled item for different style type
style2 = self.file.createIfcFillAreaStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, styles=[style2], shape_representation=representation
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, styles=[style2], shape_representation=representation
)
assert item.StyledByItem[0].Styles == (style, style2)
assert len(self.file.by_type("IfcStyledItem")) == 1
# replacing existing style of the same type
style3 = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, styles=[style3], shape_representation=representation
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, styles=[style3], shape_representation=representation
)
assert item.StyledByItem[0].Styles == (style2, style3)
assert len(self.file.by_type("IfcStyledItem")) == 1
def test_assign_using_style_assignment(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -64,8 +64,7 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
representation.Items = [item]
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style],
shape_representation=representation,
@@ -78,8 +77,7 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
# reusing existing styled item for different style type
style2 = self.file.createIfcFillAreaStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style2],
shape_representation=representation,
@@ -93,8 +91,7 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
# replacing existing style of the same type
style3 = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style3],
shape_representation=representation,
diff --git a/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py b/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py
index 54665c70d3..5875396a7a 100644
--- a/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py
@@ -18,7 +18,7 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.style
class TestEditSurfaceStyle(test.bootstrap.IFC4):
@@ -28,8 +28,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
attrs = {"SurfaceColour": {"Red": 1, "Green": 1, "Blue": 1}}
if self.file.schema != "IFC2X3":
attrs["Transparency"] = 0.5
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes=attrs,
@@ -48,8 +47,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
"SpecularColour",
]:
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={attribute: {"Red": 1, "Green": 1, "Blue": 1}},
@@ -67,8 +65,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
colour = self.file.createIfcColourRgb(None, 0, 0, 0)
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
setattr(style, attribute, colour)
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={attribute: {"Red": 1, "Green": 1, "Blue": 1}},
@@ -87,7 +84,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
colour_id = colour.id()
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
setattr(style, attribute, colour)
- ifcopenshell.api.run("style.edit_surface_style", self.file, style=style, attributes={attribute: 0.5})
+ ifcopenshell.api.style.edit_surface_style(self.file, style=style, attributes={attribute: 0.5})
with pytest.raises(RuntimeError):
self.file.by_id(colour_id)
assert getattr(style, attribute).wrappedValue == 0.5
@@ -102,7 +99,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
]:
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
setattr(style, attribute, self.file.createIfcNormalisedRatioMeasure(0.5))
- ifcopenshell.api.run("style.edit_surface_style", self.file, style=style, attributes={attribute: 0.4})
+ ifcopenshell.api.style.edit_surface_style(self.file, style=style, attributes={attribute: 0.4})
assert getattr(style, attribute).wrappedValue == 0.4
def test_editing_an_existing_factor_to_a_colour(self):
@@ -115,8 +112,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
]:
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
setattr(style, attribute, self.file.createIfcNormalisedRatioMeasure(0.5))
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={attribute: {"Red": 1, "Green": 1, "Blue": 1}},
@@ -125,8 +121,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
def test_editing_a_specular_highlight_as_an_exponent(self):
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={"SpecularHighlight": {"IfcSpecularExponent": 2}},
@@ -136,8 +131,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
def test_editing_a_specular_highlight_as_a_roughness(self):
style = self.file.createIfcSurfaceStyleRendering(self.file.createIfcColourRgb(None, 0, 0, 0))
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={"SpecularHighlight": {"IfcSpecularRoughness": 0.5}},
@@ -148,9 +142,8 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
def test_editing_texture_style(self):
style = self.file.createIfcSurfaceStyleWithTextures()
textures = ({"Mode": "DIFFUSE", "RepeatS": True, "RepeatT": True, "URLReference": "diffuse.jpg"},)
- textures = ifcopenshell.api.run("style.add_surface_textures", self.file, textures=textures)
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ textures = ifcopenshell.api.style.add_surface_textures(self.file, textures=textures)
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes={"Textures": textures},
@@ -166,8 +159,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
"ReflectanceColour",
)
attributes = {a: {"Red": 1, "Green": 1, "Blue": 1} for a in attributes}
- ifcopenshell.api.run(
- "style.edit_surface_style",
+ ifcopenshell.api.style.edit_surface_style(
self.file,
style=style,
attributes=attributes,
diff --git a/src/ifcopenshell-python/test/api/style/test_remove_style.py b/src/ifcopenshell-python/test/api/style/test_remove_style.py
index 857dec169f..c17069e889 100644
--- a/src/ifcopenshell-python/test/api/style/test_remove_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_remove_style.py
@@ -18,21 +18,21 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.style
class TestRemoveStyle(test.bootstrap.IFC4):
def test_removing_a_style(self):
shading = self.file.createIfcSurfaceStyleShading()
style = self.file.createIfcSurfaceStyle(Styles=[shading])
- ifcopenshell.api.run("style.remove_style", self.file, style=style)
+ ifcopenshell.api.style.remove_style(self.file, style=style)
assert len(list(self.file)) == 0
def test_removing_any_styled_items_referencing_the_style(self):
shading = self.file.createIfcSurfaceStyleShading()
style = self.file.createIfcSurfaceStyle(Styles=[shading])
styled_item = self.file.createIfcStyledItem(Styles=[style])
- ifcopenshell.api.run("style.remove_style", self.file, style=style)
+ ifcopenshell.api.style.remove_style(self.file, style=style)
assert len(list(self.file)) == 0
diff --git a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py
index 01394cda6c..14f8173a3a 100644
--- a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py
@@ -18,19 +18,19 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.style
class TestRemoveSurfaceStyleIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_shading_style(self):
style = self.file.createIfcSurfaceStyleShading(SurfaceColour=self.file.createIfcColourRgb(None, 1, 1, 1))
- ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
+ ifcopenshell.api.style.remove_surface_style(self.file, style=style)
assert len(list(self.file)) == 0
def test_removing_a_texture_style(self):
texture = self.file.createIfcImageTexture()
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
- ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
+ ifcopenshell.api.style.remove_surface_style(self.file, style=style)
assert len(list(self.file)) == 0
def test_removing_a_rendering_style(self):
@@ -46,7 +46,7 @@ class TestRemoveSurfaceStyleIFC2X3(test.bootstrap.IFC2X3):
# remove entity_instances() without an ID if we create them afresh, but
# will segfault if we load them stale.
g = ifcopenshell.file.from_string(self.file.wrapped_data.to_string())
- ifcopenshell.api.run("style.remove_surface_style", g, style=g.by_type("IfcSurfaceStyleRendering")[0])
+ ifcopenshell.api.style.remove_surface_style(g, style=g.by_type("IfcSurfaceStyleRendering")[0])
assert len(list(g)) == 0
@@ -56,5 +56,5 @@ class TestRemoveSurfaceStyleIFC4(test.bootstrap.IFC4, TestRemoveSurfaceStyleIFC2
texture = self.file.createIfcImageTexture()
coordinates = self.file.createIfcTextureCoordinateGenerator(Maps=[texture])
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
- ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
+ ifcopenshell.api.style.remove_surface_style(self.file, style=style)
assert len(list(self.file)) == 0
diff --git a/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py b/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py
index f1e2b1c8a3..b009de1616 100644
--- a/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py
+++ b/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py
@@ -16,26 +16,25 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.style
+import ifcopenshell.api.material
class TestUnassignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
def test_run(self):
- material = ifcopenshell.api.run("material.add_material", self.file)
+ material = ifcopenshell.api.material.add_material(self.file)
context = self.file.createIfcGeometricRepresentationContext()
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
# unassign 1 style
style2 = self.file.createIfcSurfaceStyle()
item = self.file.by_type("IfcStyledItem")[0]
item.Styles = item.Styles + (style2,)
- ifcopenshell.api.run(
- "style.unassign_material_style", self.file, material=material, style=style2, context=context
- )
+ ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style2, context=context)
if self.file.schema != "IFC2X3":
assert item.Styles == (style,)
else:
@@ -44,9 +43,7 @@ class TestUnassignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
assert item.Styles[0].Styles == (style,)
# unassign last style
- ifcopenshell.api.run(
- "style.unassign_material_style", self.file, material=material, style=style, context=context
- )
+ ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style, context=context)
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 0
assert len(self.file.by_type("IfcStyledRepresentation")) == 0
assert len(self.file.by_type("IfcStyledItem")) == 0
@@ -57,7 +54,7 @@ class TestUnassignMaterialStyleIFC4(test.bootstrap.IFC4, TestUnassignMaterialSty
def test_update_shape_aspect_representaitons_items_styles_if_material_is_part_of_matching_material_constituents(
self,
):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
name = "Concrete"
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -71,19 +68,15 @@ class TestUnassignMaterialStyleIFC4(test.bootstrap.IFC4, TestUnassignMaterialSty
shape_aspect.PartOfProductDefinitionShape = product_shape
style = self.file.createIfcSurfaceStyle()
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
- )
- constituent = ifcopenshell.api.run(
- "material.add_constituent", self.file, constituent_set=material_set, material=material
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
+ constituent = ifcopenshell.api.material.add_constituent(
+ self.file, constituent_set=material_set, material=material
)
constituent.Name = name
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
- ifcopenshell.api.run(
- "style.unassign_material_style", self.file, material=material, style=style, context=context
- )
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
+ ifcopenshell.api.style.unassign_material_style(self.file, material=material, style=style, context=context)
assert len(item.StyledByItem) == 0
diff --git a/src/ifcopenshell-python/test/api/style/test_unassign_representation_styles.py b/src/ifcopenshell-python/test/api/style/test_unassign_representation_styles.py
index b3b219c1f0..2138f6cb9b 100644
--- a/src/ifcopenshell-python/test/api/style/test_unassign_representation_styles.py
+++ b/src/ifcopenshell-python/test/api/style/test_unassign_representation_styles.py
@@ -16,15 +16,15 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.style
class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -33,12 +33,11 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
representation.Items = [item]
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, styles=[style], shape_representation=representation
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, styles=[style], shape_representation=representation
)
style2 = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style2],
shape_representation=representation,
@@ -46,20 +45,20 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
)
assert item.StyledByItem[0].Styles == (style, style2)
- ifcopenshell.api.run(
- "style.unassign_representation_styles", self.file, styles=[style], shape_representation=representation
+ ifcopenshell.api.style.unassign_representation_styles(
+ self.file, styles=[style], shape_representation=representation
)
assert item.StyledByItem[0].Styles == (style2,)
# unassigning last style removes styled item
- ifcopenshell.api.run(
- "style.unassign_representation_styles", self.file, styles=[style2], shape_representation=representation
+ ifcopenshell.api.style.unassign_representation_styles(
+ self.file, styles=[style2], shape_representation=representation
)
assert len(item.StyledByItem) == 0
assert len(self.file.by_type("IfcStyledItem")) == 0
def test_assign_using_style_assignment(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -68,8 +67,7 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
representation.Items = [item]
style = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style],
shape_representation=representation,
@@ -79,8 +77,7 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
# reusing existing styled item and style assignment
style2 = self.file.createIfcSurfaceStyle()
- ifcopenshell.api.run(
- "style.assign_representation_styles",
+ ifcopenshell.api.style.assign_representation_styles(
self.file,
styles=[style2],
shape_representation=representation,
@@ -89,8 +86,7 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
)
assert style_assignment.Styles == (style, style2)
- ifcopenshell.api.run(
- "style.unassign_representation_styles",
+ ifcopenshell.api.style.unassign_representation_styles(
self.file,
styles=[style],
shape_representation=representation,
@@ -99,8 +95,7 @@ class TestUnassignRepresentationStyles(test.bootstrap.IFC4):
assert style_assignment.Styles == (style2,)
# unassigning last style removes styled item and presentation style
- ifcopenshell.api.run(
- "style.unassign_representation_styles",
+ ifcopenshell.api.style.unassign_representation_styles(
self.file,
styles=[style2],
shape_representation=representation,
diff --git a/src/ifcopenshell-python/test/api/system/test_add_port.py b/src/ifcopenshell-python/test/api/system/test_add_port.py
index 5a1a06f59f..c2c420427c 100644
--- a/src/ifcopenshell-python/test/api/system/test_add_port.py
+++ b/src/ifcopenshell-python/test/api/system/test_add_port.py
@@ -17,17 +17,18 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestAddPort(test.bootstrap.IFC4):
def test_run(self):
- assert ifcopenshell.api.run("system.add_port", self.file).is_a("IfcDistributionPort")
+ assert ifcopenshell.api.system.add_port(self.file).is_a("IfcDistributionPort")
def test_assigning_a_port_as_well_if_an_element_is_specified(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
- port = ifcopenshell.api.run("system.add_port", self.file, element=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowTerminal")
+ port = ifcopenshell.api.system.add_port(self.file, element=element)
assert ifcopenshell.util.system.get_ports(element) == [port]
diff --git a/src/ifcopenshell-python/test/api/system/test_add_system.py b/src/ifcopenshell-python/test/api/system/test_add_system.py
index 2c0ed31b8a..8d98d5c3dd 100644
--- a/src/ifcopenshell-python/test/api/system/test_add_system.py
+++ b/src/ifcopenshell-python/test/api/system/test_add_system.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.system
class TestAddSystem(test.bootstrap.IFC4):
def test_adding_a_system(self):
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- system2 = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcDistributionSystem")
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ system2 = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcDistributionSystem")
assert system.is_a("IfcSystem")
if self.file.schema == "IFC2X3":
assert system2.is_a("IfcSystem")
diff --git a/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py b/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py
index 038b22b83a..e3d1df3bec 100644
--- a/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py
+++ b/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.system
class TestAssignFlowControl(test.bootstrap.IFC4):
@@ -26,8 +26,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
flow_control = self.file.create_entity("IfcDistributionControlElement")
# simple assignment
- relation = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element,
@@ -37,8 +36,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
assert relation.RelatedControlElements == (flow_control,)
# trying to establish existing relationship
- relation0 = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation0 = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element,
@@ -47,8 +45,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
# assigning same control to another object
flow_element1 = self.file.createIfcFlowSegment()
- relation = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element1,
@@ -57,8 +54,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
# assigning another control to the same object
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
- relation = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control1,
relating_flow_element=flow_element,
diff --git a/src/ifcopenshell-python/test/api/system/test_assign_port.py b/src/ifcopenshell-python/test/api/system/test_assign_port.py
index f78183cf49..5366800cbb 100644
--- a/src/ifcopenshell-python/test/api/system/test_assign_port.py
+++ b/src/ifcopenshell-python/test/api/system/test_assign_port.py
@@ -18,7 +18,10 @@
import numpy
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.root
+import ifcopenshell.api.system
+import ifcopenshell.api.geometry
import ifcopenshell.util.placement
import ifcopenshell.util.system
@@ -26,22 +29,22 @@ import ifcopenshell.util.system
class TestAssignPort(test.bootstrap.IFC4):
def test_assigning_a_port_once_only(self):
port = self.file.createIfcDistributionPort()
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
ifc2x3 = self.file.schema == "IFC2X3"
if ifc2x3:
assert element.HasPorts[0].RelatingPort == port
else:
assert element.IsNestedBy[0].RelatedObjects == (port,)
assert ifcopenshell.util.system.get_ports(element) == [port]
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
assert ifcopenshell.util.system.get_ports(element) == [port]
def test_updating_the_placement_to_be_relative_if_it_exists(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- subelement = ifcopenshell.api.run("system.add_port", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ subelement = ifcopenshell.api.system.add_port(self.file)
matrix = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -58,13 +61,13 @@ class TestAssignPort(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=element, matrix=matrix.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=subelement, matrix=submatrix.copy(), is_si=False
)
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=subelement)
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=subelement)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
diff --git a/src/ifcopenshell-python/test/api/system/test_assign_system.py b/src/ifcopenshell-python/test/api/system/test_assign_system.py
index 0026866835..22c26d9214 100644
--- a/src/ifcopenshell-python/test/api/system/test_assign_system.py
+++ b/src/ifcopenshell-python/test/api/system/test_assign_system.py
@@ -18,27 +18,28 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestAssignSystem(test.bootstrap.IFC4):
def test_assign_system(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- system = ifcopenshell.api.run("system.add_system", self.file)
- ifcopenshell.api.run("system.assign_system", self.file, products=[element, element2], system=system)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ system = ifcopenshell.api.system.add_system(self.file)
+ ifcopenshell.api.system.assign_system(self.file, products=[element, element2], system=system)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
assert set(ifcopenshell.util.system.get_system_elements(system)) == set(self.file.by_type("IfcFlowSegment"))
def test_exception_on_unassignable_elements(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
proj = self.file.createIfcProject()
- system = ifcopenshell.api.run("system.add_system", self.file)
+ system = ifcopenshell.api.system.add_system(self.file)
with pytest.raises(TypeError):
- ifcopenshell.api.run("system.assign_system", self.file, products=[element, proj], system=system)
+ ifcopenshell.api.system.assign_system(self.file, products=[element, proj], system=system)
with pytest.raises(TypeError):
- ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=proj)
+ ifcopenshell.api.system.assign_system(self.file, products=[element], system=proj)
class TestAssignSystemIFC2X3(test.bootstrap.IFC2X3, TestAssignSystem):
diff --git a/src/ifcopenshell-python/test/api/system/test_connect_port.py b/src/ifcopenshell-python/test/api/system/test_connect_port.py
index 8904ae05b6..8dd19d47fa 100644
--- a/src/ifcopenshell-python/test/api/system/test_connect_port.py
+++ b/src/ifcopenshell-python/test/api/system/test_connect_port.py
@@ -17,15 +17,16 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestConnectPort(test.bootstrap.IFC4):
def test_connecting_a_port(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2)
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port2.ConnectedTo[0].RelatedPort == port
@@ -35,11 +36,11 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 2
def test_not_connecting_a_port_twice(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port2, port2=port)
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2)
+ ifcopenshell.api.system.connect_port(self.file, port1=port2, port2=port)
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port2.ConnectedTo[0].RelatedPort == port
@@ -49,9 +50,9 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 2
def test_connecting_a_port_from_source_to_sink(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SOURCE")
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SOURCE")
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port.FlowDirection == "SOURCE"
@@ -59,9 +60,9 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 1
def test_connecting_a_port_from_sink_to_source(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SINK")
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SINK")
assert port2.ConnectedTo[0].RelatedPort == port
assert port.ConnectedFrom[0].RelatingPort == port2
assert port.FlowDirection == "SINK"
@@ -69,9 +70,9 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 1
def test_connecting_a_port_as_both_source_and_sink(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SOURCEANDSINK")
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SOURCEANDSINK")
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port2.ConnectedTo[0].RelatedPort == port
@@ -81,11 +82,11 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 2
def test_ports_can_only_connect_to_one_port_at_a_time(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- port3 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port3, direction="SOURCEANDSINK")
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SOURCE")
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ port3 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port3, direction="SOURCEANDSINK")
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SOURCE")
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port.FlowDirection == "SOURCE"
@@ -95,10 +96,10 @@ class TestConnectPort(test.bootstrap.IFC4):
assert not port3.ConnectedFrom
def test_changing_a_port_from_source_and_sink_to_only_source(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SOURCEANDSINK")
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="SOURCE")
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SOURCEANDSINK")
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="SOURCE")
assert port.ConnectedTo[0].RelatedPort == port2
assert port2.ConnectedFrom[0].RelatingPort == port
assert port.FlowDirection == "SOURCE"
@@ -106,12 +107,12 @@ class TestConnectPort(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelConnectsPorts")) == 1
def test_connecting_ports_with_a_realising_element(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowFitting")
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, element=element)
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowFitting")
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, element=element)
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement == element
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2)
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement is None
diff --git a/src/ifcopenshell-python/test/api/system/test_disconnect_port.py b/src/ifcopenshell-python/test/api/system/test_disconnect_port.py
index a19b665700..a34fdfc615 100644
--- a/src/ifcopenshell-python/test/api/system/test_disconnect_port.py
+++ b/src/ifcopenshell-python/test/api/system/test_disconnect_port.py
@@ -17,16 +17,16 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestDisconnectPort(test.bootstrap.IFC4):
def test_disconnecting_a_port(self):
- port = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="NOTDEFINED")
- ifcopenshell.api.run("system.disconnect_port", self.file, port=port)
+ port = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="NOTDEFINED")
+ ifcopenshell.api.system.disconnect_port(self.file, port=port)
assert port.FlowDirection == None
assert port2.FlowDirection == None
assert len(self.file.by_type("IfcRelConnectsPorts")) == 0
diff --git a/src/ifcopenshell-python/test/api/system/test_remove_system.py b/src/ifcopenshell-python/test/api/system/test_remove_system.py
index 6df72e687f..44e00987d6 100644
--- a/src/ifcopenshell-python/test/api/system/test_remove_system.py
+++ b/src/ifcopenshell-python/test/api/system/test_remove_system.py
@@ -17,27 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.pset
+import ifcopenshell.api.system
class TestRemoveSystem(test.bootstrap.IFC4):
def test_removing_a_system(self):
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- ifcopenshell.api.run("system.remove_system", self.file, system=system)
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ ifcopenshell.api.system.remove_system(self.file, system=system)
assert len(self.file.by_type("IfcSystem")) == 0
def test_removing_orphaned_group_relationships(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=system)
- ifcopenshell.api.run("system.remove_system", self.file, system=system)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowTerminal")
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ ifcopenshell.api.system.assign_system(self.file, products=[element], system=system)
+ ifcopenshell.api.system.remove_system(self.file, system=system)
assert not self.file.by_type("IfcRelAssignsToGroup")
def test_removing_orphaned_property_relationships(self):
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=system, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
- ifcopenshell.api.run("system.remove_system", self.file, system=system)
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=system, name="Foo_Bar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
+ ifcopenshell.api.system.remove_system(self.file, system=system)
assert not self.file.by_type("IfcRelDefinesByProperties")
assert not self.file.by_type("IfcPropertySet")
assert not self.file.by_type("IfcPropertySingleValue")
diff --git a/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py b/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py
index 1ece358dfd..22d2559561 100644
--- a/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py
+++ b/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.system
class TestUnassignFlowControl(test.bootstrap.IFC4):
@@ -26,14 +26,12 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
flow_control = self.file.create_entity("IfcDistributionControlElement")
# assign and unassign
- relation = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element,
)
- ifcopenshell.api.run(
- "system.unassign_flow_control",
+ ifcopenshell.api.system.unassign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element,
@@ -42,20 +40,17 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
# 1 element 2 controls
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
- relation = ifcopenshell.api.run(
- "system.assign_flow_control",
+ relation = ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control,
relating_flow_element=flow_element,
)
- ifcopenshell.api.run(
- "system.assign_flow_control",
+ ifcopenshell.api.system.assign_flow_control(
self.file,
related_flow_control=flow_control1,
relating_flow_element=flow_element,
)
- ifcopenshell.api.run(
- "system.unassign_flow_control",
+ ifcopenshell.api.system.unassign_flow_control(
self.file,
related_flow_control=flow_control1,
relating_flow_element=flow_element,
diff --git a/src/ifcopenshell-python/test/api/system/test_unassign_port.py b/src/ifcopenshell-python/test/api/system/test_unassign_port.py
index 3ba59bd72a..b49de25f9a 100644
--- a/src/ifcopenshell-python/test/api/system/test_unassign_port.py
+++ b/src/ifcopenshell-python/test/api/system/test_unassign_port.py
@@ -17,16 +17,17 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestAssignPort(test.bootstrap.IFC4):
def test_assigning_a_port_once_only(self):
port = self.file.createIfcDistributionPort()
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
- ifcopenshell.api.run("system.unassign_port", self.file, element=element, port=port)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
+ ifcopenshell.api.system.unassign_port(self.file, element=element, port=port)
assert ifcopenshell.util.system.get_ports(element) == []
diff --git a/src/ifcopenshell-python/test/api/system/test_unassign_system.py b/src/ifcopenshell-python/test/api/system/test_unassign_system.py
index 1bf3433825..8503dd82c3 100644
--- a/src/ifcopenshell-python/test/api/system/test_unassign_system.py
+++ b/src/ifcopenshell-python/test/api/system/test_unassign_system.py
@@ -18,21 +18,22 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system
class TestUnassignSystem(test.bootstrap.IFC4):
def test_unassign_system(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- system = ifcopenshell.api.run("system.add_system", self.file)
- ifcopenshell.api.run("system.assign_system", self.file, products=[element, element2, element3], system=system)
- ifcopenshell.api.run("system.unassign_system", self.file, products=[element2, element3], system=system)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ system = ifcopenshell.api.system.add_system(self.file)
+ ifcopenshell.api.system.assign_system(self.file, products=[element, element2, element3], system=system)
+ ifcopenshell.api.system.unassign_system(self.file, products=[element2, element3], system=system)
assert ifcopenshell.util.system.get_system_elements(system) == [element]
- ifcopenshell.api.run("system.unassign_system", self.file, products=[element], system=system)
+ ifcopenshell.api.system.unassign_system(self.file, products=[element], system=system)
assert ifcopenshell.util.system.get_system_elements(system) == []
diff --git a/src/ifcopenshell-python/test/api/type/test_assign_type.py b/src/ifcopenshell-python/test/api/type/test_assign_type.py
index b7a9550b80..23fd6b9501 100644
--- a/src/ifcopenshell-python/test/api/type/test_assign_type.py
+++ b/src/ifcopenshell-python/test/api/type/test_assign_type.py
@@ -17,7 +17,10 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.material
+import ifcopenshell.api.geometry
import ifcopenshell.util.element
import ifcopenshell.util.representation
import pytest
@@ -25,57 +28,56 @@ import pytest
class TestAssignType(test.bootstrap.IFC4):
def test_assigning_a_type(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- rel = ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ rel = ifcopenshell.api.type.assign_type(
+ self.file, related_objects=[element1, element2], relating_type=element_type
)
assert ifcopenshell.util.element.get_type(element1) == element_type
assert ifcopenshell.util.element.get_type(element2) == element_type
assert rel.is_a("IfcRelDefinesByType")
def test_doing_nothing_if_type_is_already_assigned(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
assert len([e for e in self.file]) == total_elements
def test_that_old_typing_relationships_are_updated_if_they_still_have_elements(self):
- element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type1
+ element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(
+ self.file, related_objects=[element1, element2], relating_type=element_type1
)
rel = element1.IsDefinedBy[0] if self.file.schema == "IFC2X3" else element1.IsTypedBy[0]
assert len(rel.RelatedObjects) == 2
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type2)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type2)
assert len(rel.RelatedObjects) == 1
def test_that_old_typing_relationships_are_purged_if_no_more_elements_are_nested(self):
- element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
+ element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type1)
rel_id = (element1.IsDefinedBy[0] if self.file.schema == "IFC2X3" else element1.IsTypedBy[0]).id()
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type2)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type2)
with pytest.raises(RuntimeError):
self.file.by_id(rel_id)
def test_map_representation_disabled(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.geometry.assign_representation(self.file, product=element_type, representation=rep)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(
self.file,
related_objects=[element],
relating_type=element_type,
@@ -87,29 +89,29 @@ class TestAssignType(test.bootstrap.IFC4):
assert ifcopenshell.util.element.get_material(element, should_inherit=False) == None
def test_map_representation(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=element_type, representation=rep)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
mapped_rep = ifcopenshell.util.representation.get_representation(element, context=context)
assert mapped_rep.RepresentationType == "MappedRepresentation"
assert mapped_rep.Items[0].MappingSource.MappedRepresentation == rep
def test_do_not_map_representation_if_type_was_assigned_previously(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
+ ifcopenshell.api.geometry.assign_representation(self.file, product=element_type, representation=rep)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
assert (mapped_rep := ifcopenshell.util.representation.get_representation(element1, context=context))
mapped_rep_id = mapped_rep.id()
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(
+ self.file, related_objects=[element1, element2], relating_type=element_type
)
assert (mapped_rep := ifcopenshell.util.representation.get_representation(element1, context=context))
assert mapped_rep.id() == mapped_rep_id
@@ -119,26 +121,26 @@ class TestAssignType(test.bootstrap.IFC4):
if self.file.schema != "IFC2X3":
material_types += ("IfcMaterialProfileSet",)
for material_type in material_types:
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type=material_type)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type=material_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
material = ifcopenshell.util.element.get_material(element)
assert material
assert material.is_a(f"{material_type}Usage")
def test_do_not_reassign_material_if_it_was_assigned_previously(self):
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
assert (material := ifcopenshell.util.element.get_material(element1))
material_id = material.id()
# use 2 elements to trigger material assignment code block
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(
+ self.file, related_objects=[element1, element2], relating_type=element_type
)
assert (material := ifcopenshell.util.element.get_material(element1))
assert material.id() == material_id
diff --git a/src/ifcopenshell-python/test/api/type/test_map_type_representation.py b/src/ifcopenshell-python/test/api/type/test_map_type_representation.py
index a288c60197..1540066266 100644
--- a/src/ifcopenshell-python/test/api/type/test_map_type_representation.py
+++ b/src/ifcopenshell-python/test/api/type/test_map_type_representation.py
@@ -17,16 +17,16 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.type
class TestMapTypeRepresentations(test.bootstrap.IFC4):
def test_doing_nothing_if_the_type_has_no_representation_maps(self):
element = self.file.createIfcWall()
type = self.file.createIfcWallType()
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type)
total_elements = len([e for e in self.file])
- ifcopenshell.api.run("type.map_type_representations", self.file, related_object=element, relating_type=type)
+ ifcopenshell.api.type.map_type_representations(self.file, related_object=element, relating_type=type)
assert len([e for e in self.file]) == total_elements
def test_removing_existing_element_representations_and_mapping_type_representations(self):
@@ -44,7 +44,7 @@ class TestMapTypeRepresentations(test.bootstrap.IFC4):
]
)
self.file.createIfcRelDefinesByType(RelatingType=type, RelatedObjects=[element])
- ifcopenshell.api.run("type.map_type_representations", self.file, related_object=element, relating_type=type)
+ ifcopenshell.api.type.map_type_representations(self.file, related_object=element, relating_type=type)
rep = element.Representation.Representations[0]
assert rep.RepresentationType == "MappedRepresentation"
assert rep.Items[0].MappingSource == type.RepresentationMaps[0]
diff --git a/src/ifcopenshell-python/test/api/type/test_unassign_type.py b/src/ifcopenshell-python/test/api/type/test_unassign_type.py
index 2df994f4a9..d4f3b0cfa8 100644
--- a/src/ifcopenshell-python/test/api/type/test_unassign_type.py
+++ b/src/ifcopenshell-python/test/api/type/test_unassign_type.py
@@ -16,43 +16,45 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.material
+import ifcopenshell.api.geometry
import ifcopenshell.util.element
class TestUnassignType(test.bootstrap.IFC4):
def test_unassigning_a_type(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run(
- "type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(
+ self.file, related_objects=[element1, element2], relating_type=element_type
)
- ifcopenshell.api.run("type.unassign_type", self.file, related_objects=[element1, element2])
+ ifcopenshell.api.type.unassign_type(self.file, related_objects=[element1, element2])
assert ifcopenshell.util.element.get_type(element1) is None
assert ifcopenshell.util.element.get_type(element2) is None
def test_the_rel_is_kept_if_there_are_more_typed_elements(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
- ifcopenshell.api.run("type.unassign_type", self.file, related_objects=[element1])
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
+ ifcopenshell.api.type.unassign_type(self.file, related_objects=[element1])
assert len(self.file.by_type("IfcRelDefinesByType")) == 1
def test_the_rel_is_purged_if_there_are_no_more_typed_elements(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
- ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
+ ifcopenshell.api.geometry.assign_representation(self.file, product=element_type, representation=rep)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("type.unassign_type", self.file, related_objects=[element])
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.type.unassign_type(self.file, related_objects=[element])
assert len(self.file.by_type("IfcRelDefinesByType")) == 0
diff --git a/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py
index 7d6887a893..705a2f0815 100644
--- a/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_add_context_dependent_unit.py
@@ -17,13 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestAddContextDependentUnit(test.bootstrap.IFC4):
def test_run(self):
- unit = ifcopenshell.api.run(
- "unit.add_context_dependent_unit",
+ unit = ifcopenshell.api.unit.add_context_dependent_unit(
self.file,
unit_type="LENGTHUNIT",
name="foobar",
diff --git a/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py
index 87f3513191..03a8a7edfd 100644
--- a/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_add_conversion_based_unit.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestAddConversionBasedUnitIFC2X3(test.bootstrap.IFC2X3):
def test_run(self):
- unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot")
+ unit = ifcopenshell.api.unit.add_conversion_based_unit(self.file, name="foot")
assert unit.is_a("IfcConversionBasedUnit")
assert unit.Dimensions.LengthExponent == 1
assert unit.Dimensions.MassExponent == 0
@@ -43,7 +43,7 @@ class TestAddConversionBasedUnitIFC2X3(test.bootstrap.IFC2X3):
class TestAddConversionBasedUnitIFC4(test.bootstrap.IFC4, TestAddConversionBasedUnitIFC2X3):
def test_adding_a_unit_with_offset(self):
- unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="fahrenheit")
+ unit = ifcopenshell.api.unit.add_conversion_based_unit(self.file, name="fahrenheit")
assert unit.is_a("IfcConversionBasedUnitWithOffset")
assert unit.Dimensions.LengthExponent == 0
assert unit.Dimensions.MassExponent == 0
diff --git a/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py
index 47d23505ec..3d3e44bfe4 100644
--- a/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_add_monetary_unit.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestAddMonetaryUnit(test.bootstrap.IFC4):
def test_run(self):
- unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
+ unit = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
assert unit.is_a("IfcMonetaryUnit")
assert unit.Currency == "USD"
diff --git a/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py b/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py
index 2c31cef495..f618f9871e 100644
--- a/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_add_si_unit.py
@@ -17,12 +17,12 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestAddSIUnit(test.bootstrap.IFC4):
def test_run(self):
- unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI")
+ unit = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="LENGTHUNIT", prefix="MILLI")
assert unit.UnitType == "LENGTHUNIT"
assert unit.Name == "METRE"
assert unit.Prefix == "MILLI"
diff --git a/src/ifcopenshell-python/test/api/unit/test_assign_unit.py b/src/ifcopenshell-python/test/api/unit/test_assign_unit.py
index c16c423a9a..d2d58eaf2c 100644
--- a/src/ifcopenshell-python/test/api/unit/test_assign_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_assign_unit.py
@@ -17,15 +17,15 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestAssignUnit(test.bootstrap.IFC4):
def test_run(self):
project = self.file.createIfcProject()
- unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
- unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY")
- assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2])
+ unit1 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
+ unit2 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="JPY")
+ assignment = ifcopenshell.api.unit.assign_unit(self.file, units=[unit1, unit2])
assert project.UnitsInContext == assignment
assert assignment.is_a("IfcUnitAssignment")
assert unit1 in assignment.Units
@@ -33,10 +33,10 @@ class TestAssignUnit(test.bootstrap.IFC4):
def test_assign_units_to_an_existing_assignment(self):
project = self.file.createIfcProject()
- unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
- unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY")
- assignment1 = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1])
- assignment2 = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit2])
+ unit1 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
+ unit2 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="JPY")
+ assignment1 = ifcopenshell.api.unit.assign_unit(self.file, units=[unit1])
+ assignment2 = ifcopenshell.api.unit.assign_unit(self.file, units=[unit2])
assert project.UnitsInContext == assignment1
assert assignment1 == assignment2
assert unit1 in assignment1.Units
diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py
index 3657fb0511..679f5602b7 100644
--- a/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_edit_derived_unit.py
@@ -17,14 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestEditDerivedUnit(test.bootstrap.IFC4):
def test_run(self):
unit = self.file.createIfcDerivedUnit()
- ifcopenshell.api.run(
- "unit.edit_derived_unit",
+ ifcopenshell.api.unit.edit_derived_unit(
self.file,
unit=unit,
attributes={"UnitType": "USERDEFINED", "UserDefinedType": "UserDefinedType"},
diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py
index a2d780bfb7..d956b2fb04 100644
--- a/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_edit_monetary_unit.py
@@ -17,13 +17,13 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestEditMonetaryUnit(test.bootstrap.IFC4):
def test_run(self):
unit = self.file.createIfcMonetaryUnit()
- ifcopenshell.api.run("unit.edit_monetary_unit", self.file, unit=unit, attributes={"Currency": "USD"})
+ ifcopenshell.api.unit.edit_monetary_unit(self.file, unit=unit, attributes={"Currency": "USD"})
assert unit.Currency == "USD"
diff --git a/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py b/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py
index ffaca2d32b..cc99e69eae 100644
--- a/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_edit_named_unit.py
@@ -17,15 +17,14 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestEditNamedUnitIFC2X3(test.bootstrap.IFC2X3):
def test_edit_context_dependent_unit(self):
unit = self.file.createIfcContextDependentUnit()
unit.Dimensions = self.file.createIfcDimensionalExponents()
- ifcopenshell.api.run(
- "unit.edit_named_unit",
+ ifcopenshell.api.unit.edit_named_unit(
self.file,
unit=unit,
attributes={"Dimensions": (1, 2, 3, 4, 5, 6, 7), "UnitType": "LENGTHUNIT", "Name": "Name"},
@@ -36,8 +35,7 @@ class TestEditNamedUnitIFC2X3(test.bootstrap.IFC2X3):
def test_edit_si_unit(self):
unit = self.file.createIfcSIUnit()
- ifcopenshell.api.run(
- "unit.edit_named_unit",
+ ifcopenshell.api.unit.edit_named_unit(
self.file,
unit=unit,
attributes={"UnitType": "LENGTHUNIT", "Prefix": "MILLI", "Name": "METRE"},
@@ -49,8 +47,7 @@ class TestEditNamedUnitIFC2X3(test.bootstrap.IFC2X3):
def test_edit_conversion_based_unit(self):
unit = self.file.createIfcConversionBasedUnit()
unit.Dimensions = self.file.createIfcDimensionalExponents()
- ifcopenshell.api.run(
- "unit.edit_named_unit",
+ ifcopenshell.api.unit.edit_named_unit(
self.file,
unit=unit,
attributes={"Dimensions": (1, 2, 3, 4, 5, 6, 7), "UnitType": "LENGTHUNIT", "Name": "Name"},
@@ -64,8 +61,7 @@ class TestEditNamedUnitIFC4(test.bootstrap.IFC4, TestEditNamedUnitIFC2X3):
def test_edit_conversion_based_unit_with_offset(self):
unit = self.file.createIfcConversionBasedUnitWithOffset()
unit.Dimensions = self.file.createIfcDimensionalExponents()
- ifcopenshell.api.run(
- "unit.edit_named_unit",
+ ifcopenshell.api.unit.edit_named_unit(
self.file,
unit=unit,
attributes={
diff --git a/src/ifcopenshell-python/test/api/unit/test_remove_unit.py b/src/ifcopenshell-python/test/api/unit/test_remove_unit.py
index c53d66e2eb..ef6732259a 100644
--- a/src/ifcopenshell-python/test/api/unit/test_remove_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_remove_unit.py
@@ -17,20 +17,20 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestRemoveUnit(test.bootstrap.IFC4):
def test_remove_a_single_unit(self):
unit = self.file.createIfcContextDependentUnit()
- ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit)
+ ifcopenshell.api.unit.remove_unit(self.file, unit=unit)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
def test_remove_the_only_assigned_unit(self):
self.file.createIfcProject()
unit = self.file.createIfcContextDependentUnit()
- ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
- ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit)
+ ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
+ ifcopenshell.api.unit.remove_unit(self.file, unit=unit)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
assert len(self.file.by_type("IfcUnitAssignment")) == 0
@@ -38,14 +38,14 @@ class TestRemoveUnit(test.bootstrap.IFC4):
self.file.createIfcProject()
unit1 = self.file.createIfcContextDependentUnit()
unit2 = self.file.createIfcSIUnit()
- assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2])
- ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit1)
+ assignment = ifcopenshell.api.unit.assign_unit(self.file, units=[unit1, unit2])
+ ifcopenshell.api.unit.remove_unit(self.file, unit=unit1)
assert len(self.file.by_type("IfcContextDependentUnit")) == 0
assert assignment.Units == (unit2,)
def test_removing_a_unit_deeply(self):
- unit = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot")
- ifcopenshell.api.run("unit.remove_unit", self.file, unit=unit)
+ unit = ifcopenshell.api.unit.add_conversion_based_unit(self.file, name="foot")
+ ifcopenshell.api.unit.remove_unit(self.file, unit=unit)
assert len([e for e in self.file]) == 0
diff --git a/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py b/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py
index 13087d9e00..5a101e2018 100644
--- a/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py
+++ b/src/ifcopenshell-python/test/api/unit/test_unassign_unit.py
@@ -17,29 +17,29 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
class TestUnassignUnit(test.bootstrap.IFC4):
def test_run(self):
project = self.file.createIfcProject()
- unit1 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
- unit2 = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="JPY")
- assignment = ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit1, unit2])
- ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit1])
+ unit1 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
+ unit2 = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="JPY")
+ assignment = ifcopenshell.api.unit.assign_unit(self.file, units=[unit1, unit2])
+ ifcopenshell.api.unit.unassign_unit(self.file, units=[unit1])
assert unit1 not in assignment.Units
assert unit2 in assignment.Units
def test_unassigning_the_last_unit(self):
project = self.file.createIfcProject()
- unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
- ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
- ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit])
+ unit = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
+ ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
+ ifcopenshell.api.unit.unassign_unit(self.file, units=[unit])
assert project.UnitsInContext is None
def test_doing_nothing_if_the_unit_is_not_assigned(self):
- unit = ifcopenshell.api.run("unit.add_monetary_unit", self.file, currency="USD")
- assert ifcopenshell.api.run("unit.unassign_unit", self.file, units=[unit]) is None
+ unit = ifcopenshell.api.unit.add_monetary_unit(self.file, currency="USD")
+ assert ifcopenshell.api.unit.unassign_unit(self.file, units=[unit]) is None
class TestUnassignUnitIFC2X3(test.bootstrap.IFC2X3, TestUnassignUnit):
diff --git a/src/ifcopenshell-python/test/api/void/test_add_filling.py b/src/ifcopenshell-python/test/api/void/test_add_filling.py
index c29da2323d..7e0e2edabe 100644
--- a/src/ifcopenshell-python/test/api/void/test_add_filling.py
+++ b/src/ifcopenshell-python/test/api/void/test_add_filling.py
@@ -17,30 +17,31 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.void
+import ifcopenshell.api.root
class TestAddFilling(test.bootstrap.IFC4):
def test_adding_a_filling(self):
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
assert door.FillsVoids[0].RelatingOpeningElement == opening
def test_adding_a_filling_twice(self):
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
assert door.FillsVoids[0].RelatingOpeningElement == opening
assert len(opening.HasFillings) == 1
def test_adding_a_filling_which_is_already_filling_another_opening(self):
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- opening1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- opening2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening1, element=door)
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening2, element=door)
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ opening1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ opening2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_filling(self.file, opening=opening1, element=door)
+ ifcopenshell.api.void.add_filling(self.file, opening=opening2, element=door)
assert not opening1.HasFillings
assert opening2.HasFillings[0].RelatedBuildingElement == door
diff --git a/src/ifcopenshell-python/test/api/void/test_add_opening.py b/src/ifcopenshell-python/test/api/void/test_add_opening.py
index 4a168eead0..c36912d5b9 100644
--- a/src/ifcopenshell-python/test/api/void/test_add_opening.py
+++ b/src/ifcopenshell-python/test/api/void/test_add_opening.py
@@ -18,38 +18,41 @@
import numpy
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.void
+import ifcopenshell.api.root
+import ifcopenshell.api.unit
+import ifcopenshell.api.geometry
class TestAddOpening(test.bootstrap.IFC4):
def test_adding_an_opening(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
assert wall.HasOpenings[0].RelatedOpeningElement == opening
def test_adding_an_opening_twice(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
assert wall.HasOpenings[0].RelatedOpeningElement == opening
assert len(wall.HasOpenings) == 1
def test_adding_an_opening_which_is_already_voiding_another_element(self):
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=slab)
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=slab)
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
assert not slab.HasOpenings
assert wall.HasOpenings[0].RelatedOpeningElement == opening
def test_assigning_an_opening_does_not_shift_object_placements(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
matrix1 = numpy.array(
(
(1.0, 0.0, 0.0, 1.0),
@@ -58,24 +61,24 @@ class TestAddOpening(test.bootstrap.IFC4):
(0.0, 0.0, 0.0, 1.0),
)
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=wall, matrix=matrix1.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=wall, matrix=matrix1.copy(), is_si=False
)
- ifcopenshell.api.run(
- "geometry.edit_object_placement", self.file, product=opening, matrix=matrix1.copy(), is_si=False
+ ifcopenshell.api.geometry.edit_object_placement(
+ self.file, product=opening, matrix=matrix1.copy(), is_si=False
)
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
assert opening.ObjectPlacement.PlacementRelTo.PlacesObject[0] == wall
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(opening.ObjectPlacement), matrix1)
def test_not_updating_placement_if_placement_is_not_relative(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
placement = self.file.createIfcGridPlacement()
opening.ObjectPlacement = placement
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
assert opening.ObjectPlacement == placement
diff --git a/src/ifcopenshell-python/test/api/void/test_remove_opening.py b/src/ifcopenshell-python/test/api/void/test_remove_opening.py
index fd176cb7fc..02beb80b23 100644
--- a/src/ifcopenshell-python/test/api/void/test_remove_opening.py
+++ b/src/ifcopenshell-python/test/api/void/test_remove_opening.py
@@ -17,31 +17,32 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.void
+import ifcopenshell.api.root
class TestRemoveOpening(test.bootstrap.IFC4):
def test_removing_a_simple_opening(self):
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.remove_opening", self.file, opening=opening)
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.remove_opening(self.file, opening=opening)
assert len(list(self.file)) == 0
def test_removing_an_opening_voiding_a_wall(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- ifcopenshell.api.run("void.remove_opening", self.file, opening=opening)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.remove_opening(self.file, opening=opening)
assert len(self.file.by_type("IfcOpeningElement")) == 0
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
assert wall
def test_removing_an_opening_voiding_a_wall_with_a_filling(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
- ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
- ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
- ifcopenshell.api.run("void.remove_opening", self.file, opening=opening)
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
+ ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
+ ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
+ ifcopenshell.api.void.remove_opening(self.file, opening=opening)
assert len(self.file.by_type("IfcOpeningElement")) == 0
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
assert len(self.file.by_type("IfcRelFillsElement")) == 0
diff --git a/src/ifcopenshell-python/test/bootstrap.py b/src/ifcopenshell-python/test/bootstrap.py
index c23d2ddba9..8fa9c5b20b 100644
--- a/src/ifcopenshell-python/test/bootstrap.py
+++ b/src/ifcopenshell-python/test/bootstrap.py
@@ -18,14 +18,14 @@
import pytest
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.project
import ifcopenshell.api.owner.settings
class IFC4X3:
@pytest.fixture(autouse=True)
def setup(self):
- self.file: ifcopenshell.file = ifcopenshell.api.run("project.create_file", version="IFC4X3")
+ self.file: ifcopenshell.file = ifcopenshell.api.project.create_file(version="IFC4X3")
ifcopenshell.api.owner.settings.get_user = lambda ifc: (ifc.by_type("IfcPersonAndOrganization") or [None])[0]
ifcopenshell.api.owner.settings.get_application = lambda ifc: (ifc.by_type("IfcApplication") or [None])[0]
ifcopenshell.api.pre_listeners = {}
@@ -35,7 +35,7 @@ class IFC4X3:
class IFC4:
@pytest.fixture(autouse=True)
def setup(self):
- self.file: ifcopenshell.file = ifcopenshell.api.run("project.create_file")
+ self.file: ifcopenshell.file = ifcopenshell.api.project.create_file()
ifcopenshell.api.owner.settings.get_user = lambda ifc: (ifc.by_type("IfcPersonAndOrganization") or [None])[0]
ifcopenshell.api.owner.settings.get_application = lambda ifc: (ifc.by_type("IfcApplication") or [None])[0]
ifcopenshell.api.pre_listeners = {}
@@ -45,7 +45,7 @@ class IFC4:
class IFC2X3:
@pytest.fixture(autouse=True)
def setup(self):
- self.file: ifcopenshell.file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
+ self.file: ifcopenshell.file = ifcopenshell.api.project.create_file(version="IFC2X3")
def get_user(ifc: ifcopenshell.file) -> ifcopenshell.entity_instance:
user = next(iter(ifc.by_type("IfcPersonAndOrganization")), None)
diff --git a/src/ifcopenshell-python/test/file_gc.py b/src/ifcopenshell-python/test/file_gc.py
index 07d0f18ae2..85d2d70e43 100644
--- a/src/ifcopenshell-python/test/file_gc.py
+++ b/src/ifcopenshell-python/test/file_gc.py
@@ -4,7 +4,11 @@ import weakref
import itertools
import ifcopenshell
import ifcopenshell.guid
-import ifcopenshell.api
+import ifcopenshell.api.pset
+import ifcopenshell.api.owner
+import ifcopenshell.api.project
+import ifcopenshell.api.material
+import ifcopenshell.api.attribute
import ifcopenshell.template
@@ -25,37 +29,30 @@ def test_file_gc(args):
if do_run_api:
if api == 0:
- ifcopenshell.api.run(
- "attribute.edit_attributes",
+ ifcopenshell.api.attribute.edit_attributes(
f,
product=inst,
attributes={"FamilyName": "Bimson"},
)
elif api == 1:
- ifcopenshell.api.run(
- "pset.add_pset", f, product=inst, name="ePSet_MapConversion"
- )
+ ifcopenshell.api.pset.add_pset(f, product=inst, name="ePSet_MapConversion")
elif api == 2:
pset = f.create_entity(
"IfcPropertySet",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run(
- "owner.create_owner_history", f
- ),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(f),
"Name": "ePSet_MapConversion",
- }
+ },
)
f.create_entity(
"IfcRelDefinesByProperties",
**{
"GlobalId": ifcopenshell.guid.new(),
- "OwnerHistory": ifcopenshell.api.run(
- "owner.create_owner_history", f
- ),
+ "OwnerHistory": ifcopenshell.api.owner.create_owner_history(f),
"RelatedObjects": [inst],
"RelatingPropertyDefinition": pset,
- }
+ },
)
del pset
@@ -78,8 +75,8 @@ def test_file_gc(args):
def test_bug_2517():
- fixtures = os.path.join(os.path.dirname(__file__), 'fixtures')
- model = ifcopenshell.open(f'{fixtures}/bug_2517_test2.ifc')
+ fixtures = os.path.join(os.path.dirname(__file__), "fixtures")
+ model = ifcopenshell.open(f"{fixtures}/bug_2517_test2.ifc")
library = ifcopenshell.open(f"{fixtures}/bug_2517_lib.ifc")
result = model.add(library.by_type("IfcClassification")[0])
model.create_entity(
@@ -91,23 +88,19 @@ def test_bug_2517():
def test_bug_2486_a():
- run = ifcopenshell.api.run
+ file = ifcopenshell.api.project.create_file()
- file = run("project.create_file")
-
- mymaterial = run("material.add_material", file)
- pset = run("pset.add_pset", file, product=mymaterial)
- run(
- "pset.edit_pset",
+ mymaterial = ifcopenshell.api.material.add_material(file)
+ pset = ifcopenshell.api.pset.add_pset(file, product=mymaterial)
+ ifcopenshell.api.pset.edit_pset(
file,
pset=pset,
properties={"foo": "bar"},
)
- another_file = run("project.create_file")
+ another_file = ifcopenshell.api.project.create_file()
- run(
- "project.append_asset",
+ ifcopenshell.api.project.append_asset(
another_file,
library=file,
element=mymaterial,
diff --git a/src/ifcopenshell-python/test/fixtures/validate/generate_00.py b/src/ifcopenshell-python/test/fixtures/validate/generate_00.py
index e552a18970..082804fa26 100644
--- a/src/ifcopenshell-python/test/fixtures/validate/generate_00.py
+++ b/src/ifcopenshell-python/test/fixtures/validate/generate_00.py
@@ -1,5 +1,6 @@
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.owner
from pathlib import Path
@@ -12,13 +13,13 @@ for schema in ("ifc2x3", "ifc4", "ifc4x3"):
# setup IfcOwnerHistory
if schema == "ifc2x3":
- ifcopenshell.api.run("owner.add_application", f)
- person = ifcopenshell.api.run("owner.add_person", f)
- organization = ifcopenshell.api.run("owner.add_organisation", f)
- ifcopenshell.api.run("owner.add_person_and_organisation", f, person=person, organisation=organization)
+ ifcopenshell.api.owner.add_application(f)
+ person = ifcopenshell.api.owner.add_person(f)
+ organization = ifcopenshell.api.owner.add_organisation(f)
+ ifcopenshell.api.owner.add_person_and_organisation(f, person=person, organisation=organization)
- wall1 = ifcopenshell.api.run("root.create_entity", f)
- wall2 = ifcopenshell.api.run("root.create_entity", f)
+ wall1 = ifcopenshell.api.root.create_entity(f)
+ wall2 = ifcopenshell.api.root.create_entity(f)
wall1.GlobalId = guid1
wall2.GlobalId = guid1 if status == "fail" else guid2
diff --git a/src/ifcopenshell-python/test/test_create_shape.py b/src/ifcopenshell-python/test/test_create_shape.py
index e3c571f05c..aec58b4cdc 100644
--- a/src/ifcopenshell-python/test/test_create_shape.py
+++ b/src/ifcopenshell-python/test/test_create_shape.py
@@ -1,6 +1,9 @@
import pytest
import ifcopenshell
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.root
+import ifcopenshell.api.context
+import ifcopenshell.api.project
import ifcopenshell.geom
import ifcopenshell.api.owner.settings
from typing import get_args
@@ -45,23 +48,15 @@ class TestGeomSettings:
class TestAssignObject:
def test_no_welding_on_distinct_items(self):
- self.file = ifcopenshell.api.run("project.create_file")
+ self.file = ifcopenshell.api.project.create_file()
ifcopenshell.api.owner.settings.get_user = lambda ifc: (ifc.by_type("IfcPersonAndOrganization") or [None])[0]
ifcopenshell.api.owner.settings.get_application = lambda ifc: (ifc.by_type("IfcApplication") or [None])[0]
-
- ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcProject", name="Test"
- )
- unit = ifcopenshell.api.run(
- "unit.add_si_unit", self.file, unit_type="LENGTHUNIT"
- )
- ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit])
- context = ifcopenshell.api.run(
- "context.add_context", self.file, context_type="Model"
- )
- element = ifcopenshell.api.run(
- "root.create_entity", self.file, ifc_class="IfcWall"
- )
+
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject", name="Test")
+ unit = ifcopenshell.api.unit.add_si_unit(self.file, unit_type="LENGTHUNIT")
+ ifcopenshell.api.unit.assign_unit(self.file, units=[unit])
+ context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
def create_extrusion(x, y):
points = (
@@ -71,9 +66,7 @@ class TestAssignObject:
(x + 1.0, y + 0.0),
(x + 0.0, y + 0.0),
)
- curve = self.file.createIfcPolyline(
- [self.file.createIfcCartesianPoint(p) for p in points]
- )
+ curve = self.file.createIfcPolyline([self.file.createIfcCartesianPoint(p) for p in points])
extrusion_direction = self.file.createIfcDirection((0.0, 0.0, 1.0))
return self.file.createIfcExtrudedAreaSolid(
self.file.createIfcArbitraryClosedProfileDef("AREA", None, curve),
@@ -96,21 +89,14 @@ class TestAssignObject:
]
)
- obj = ifcopenshell.geom.create_shape(
- ifcopenshell.geom.settings(WELD_VERTICES=True), element
- )
+ obj = ifcopenshell.geom.create_shape(ifcopenshell.geom.settings(WELD_VERTICES=True), element)
# item_ids is a per-triangle array, so we have 12 triangles per cube
# even though not documented, the order in representation items should match
- assert (
- obj.geometry.item_ids
- == (extrusions[0].id(),) * 12 + (extrusions[1].id(),) * 12
- )
+ assert obj.geometry.item_ids == (extrusions[0].id(),) * 12 + (extrusions[1].id(),) * 12
# group the vertices
- vs = [
- obj.geometry.verts[i : i + 3] for i in range(0, len(obj.geometry.verts), 3)
- ]
+ vs = [obj.geometry.verts[i : i + 3] for i in range(0, len(obj.geometry.verts), 3)]
# welding should not happen between distinct items so the total number of verts should be 2 times 8
assert len(vs) == 16
diff --git a/src/ifcopenshell-python/test/util/test_brick.py b/src/ifcopenshell-python/test/util/test_brick.py
index 78b7771d57..61a9f413af 100644
--- a/src/ifcopenshell-python/test/util/test_brick.py
+++ b/src/ifcopenshell-python/test/util/test_brick.py
@@ -18,7 +18,8 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
import ifcopenshell.util.brick as subject
@@ -34,7 +35,7 @@ class TestGetBrickTypeIFC4(test.bootstrap.IFC4):
class TestGetBrickTypeIFC2X3(test.bootstrap.IFC2X3):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowController")
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcAirTerminalBoxType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type_element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowController")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcAirTerminalBoxType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type_element)
assert subject.get_brick_type(element) == "https://brickschema.org/schema/Brick#TerminalUnit"
diff --git a/src/ifcopenshell-python/test/util/test_classification.py b/src/ifcopenshell-python/test/util/test_classification.py
index 7fe054e1e3..eb3d6a9a54 100644
--- a/src/ifcopenshell-python/test/util/test_classification.py
+++ b/src/ifcopenshell-python/test/util/test_classification.py
@@ -16,9 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.classification
import ifcopenshell.util.classification as subject
@@ -28,18 +29,16 @@ class TestGetReferences(test.bootstrap.IFC4):
classification = library.createIfcClassification(Name="Name")
reference1 = library.createIfcClassificationReference(Identification="1", ReferencedSource=classification)
reference2 = library.createIfcClassificationReference(Identification="2", ReferencedSource=classification)
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
- ifcopenshell.api.run(
- "classification.add_reference",
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.classification.add_classification(self.file, classification=classification)
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
reference=reference1,
classification=classification,
)
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
reference=reference2,
@@ -48,11 +47,10 @@ class TestGetReferences(test.bootstrap.IFC4):
assert subject.get_references(element) == set(self.file.by_type("IfcClassificationReference"))
def test_get_references_of_a_non_rooted_element(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
element = self.file.createIfcMaterial()
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- ifcopenshell.api.run(
- "classification.add_reference",
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
identification="X",
@@ -66,20 +64,18 @@ class TestGetReferences(test.bootstrap.IFC4):
classification = library.createIfcClassification(Name="Name")
reference1 = library.createIfcClassificationReference(Identification="1", ReferencedSource=classification)
reference2 = library.createIfcClassificationReference(Identification="2", ReferencedSource=classification)
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
- ifcopenshell.api.run(
- "classification.add_reference",
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.classification.add_classification(self.file, classification=classification)
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
reference=reference1,
classification=classification,
)
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element_type],
reference=reference2,
@@ -95,20 +91,18 @@ class TestGetReferences(test.bootstrap.IFC4):
classification = library.createIfcClassification(Name="Name")
reference1 = library.createIfcClassificationReference(Identification="1", ReferencedSource=classification)
reference2 = library.createIfcClassificationReference(Identification="2", ReferencedSource=classification)
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
- ifcopenshell.api.run(
- "classification.add_reference",
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.classification.add_classification(self.file, classification=classification)
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
reference=reference1,
classification=classification,
)
- ifcopenshell.api.run(
- "classification.add_reference",
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element_type],
reference=reference2,
diff --git a/src/ifcopenshell-python/test/util/test_element.py b/src/ifcopenshell-python/test/util/test_element.py
index fef03698bd..6c316d509e 100644
--- a/src/ifcopenshell-python/test/util/test_element.py
+++ b/src/ifcopenshell-python/test/util/test_element.py
@@ -18,18 +18,34 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.void
+import ifcopenshell.api.pset
+import ifcopenshell.api.root
+import ifcopenshell.api.type
+import ifcopenshell.api.nest
+import ifcopenshell.api.style
+import ifcopenshell.api.layer
+import ifcopenshell.api.library
+import ifcopenshell.api.context
+import ifcopenshell.api.spatial
+import ifcopenshell.api.geometry
+import ifcopenshell.api.sequence
+import ifcopenshell.api.classification
+import ifcopenshell.api.material
+import ifcopenshell.api.document
+import ifcopenshell.api.aggregate
+import ifcopenshell.api.group
import ifcopenshell.guid
import ifcopenshell.util.element as subject
class TestGetPsetIFC4(test.bootstrap.IFC4):
def test_getting_the_psets_of_a_product_as_a_dictionary(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_pset(element, "name") is None
assert subject.get_pset(element, "name", "a") is None
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_pset(element, "name") == {"a": "b", "id": pset.id()}
assert subject.get_pset(element, "name", "a") == "b"
assert subject.get_pset(element, "name", "a", verbose=True) == {
@@ -39,10 +55,10 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
}
def test_getting_the_psets_of_a_product_type_as_a_dictionary(self):
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
foo = subject.get_pset(type_element, "name") is None
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_pset(type_element, "name") == {"x": "y", "id": pset.id()}
assert subject.get_pset(type_element, "name", verbose=True) == {
"x": {
@@ -54,13 +70,13 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
}
def test_getting_inherited_psets(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type_element)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 1, "x": 1})
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 2, "b": 3})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type_element)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 1, "x": 1})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 2, "b": 3})
result = subject.get_pset(element, "name")
assert result["id"] == pset.id()
assert result["a"] == 2
@@ -69,8 +85,8 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
assert subject.get_pset(element, "name", "a") == 2
assert subject.get_pset(element, "name", "x") == 1
assert subject.get_pset(element, "name", "b") == 3
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name2")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"z": False})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name2")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"z": False})
assert subject.get_pset(element, "name2", "z") is False
# test filters with inherited psets
@@ -78,13 +94,13 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
assert subject.get_pset(element, "name", qtos_only=True) == None
def test_excluding_inherited_psets(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type_element)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 1, "x": 1})
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 2, "b": 3})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type_element)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 1, "x": 1})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 2, "b": 3})
result = subject.get_pset(element, "name", should_inherit=False)
assert result["id"] == pset.id()
assert result["a"] == 2
@@ -97,8 +113,8 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
material = self.file.createIfcMaterial()
assert subject.get_pset(material, "name") is None
assert subject.get_pset(material, "name", "x") is None
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_pset(material, "name") == {"x": "y", "id": pset.id()}
assert subject.get_pset(material, "name", "x") == "y"
@@ -106,8 +122,8 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
profile = self.file.createIfcCircleProfileDef()
assert subject.get_pset(profile, "name") is None
assert subject.get_pset(profile, "name", "x") is None
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=profile, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=profile, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_pset(profile, "name") == {"x": "y", "id": pset.id()}
assert subject.get_pset(profile, "name", "x") == "y"
@@ -118,27 +134,27 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
class TestGetPsetsIFC4(test.bootstrap.IFC4):
def test_getting_the_psets_of_a_product_as_a_dictionary(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_psets(element) == {}
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_psets(element) == {"name": {"a": "b", "id": pset.id()}}
def test_getting_the_psets_of_a_product_type_as_a_dictionary(self):
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
assert subject.get_psets(type_element) == {}
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_psets(type_element) == {"name": {"x": "y", "id": pset.id()}}
def test_getting_inherited_psets(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type_element)
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 1, "x": 1})
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": 2, "b": 3})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ type_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type_element)
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=type_element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 1, "x": 1})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": 2, "b": 3})
psets = subject.get_psets(element)
assert psets["name"]["id"] == pset.id()
assert psets["name"]["a"] == 2
@@ -148,58 +164,58 @@ class TestGetPsetsIFC4(test.bootstrap.IFC4):
def test_getting_the_psets_of_a_material_as_a_dictionary(self):
material = self.file.createIfcMaterial()
assert subject.get_psets(material) == {}
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_psets(material) == {"name": {"x": "y", "id": pset.id()}}
def test_getting_the_psets_of_a_profile_as_a_dictionary(self):
profile = self.file.createIfcCircleProfileDef()
assert subject.get_psets(profile) == {}
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=profile, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=profile, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"x": "y"})
assert subject.get_psets(profile) == {"name": {"x": "y", "id": pset.id()}}
def test_getting_psets_from_an_element_which_cannot_have_psets(self):
assert subject.get_psets(self.file.create_entity("IfcPerson")) == {}
def test_only_getting_psets_and_not_qtos(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="pset")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="qto")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"x": 42})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="pset")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="qto")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"x": 42})
assert subject.get_psets(element, psets_only=True) == {"pset": {"a": "b", "id": pset.id()}}
def test_only_getting_qtos_and_not_psets(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="pset")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="qto")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"x": 42})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="pset")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="qto")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"x": 42})
assert subject.get_psets(element, qtos_only=True) == {"qto": {"x": 42, "id": qto.id()}}
class TestGetPropertyDefinitionIFC4(test.bootstrap.IFC4):
def test_getting_the_properties_of_a_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_property_definition(pset) == {"a": "b", "id": pset.id()}
def test_getting_the_properties_of_a_qto(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"x": 42})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"x": 42})
assert subject.get_property_definition(qto) == {"x": 42, "id": qto.id()}
def test_getting_the_properties_of_a_material_property(self):
pset = self.file.createIfcMaterialProperties()
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_property_definition(pset) == {"a": "b", "id": pset.id()}
def test_getting_the_properties_of_a_profile_property(self):
pset = self.file.createIfcProfileProperties()
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_property_definition(pset) == {"a": "b", "id": pset.id()}
def test_getting_the_properties_of_a_predefined_pset(self):
@@ -210,29 +226,29 @@ class TestGetPropertyDefinitionIFC4(test.bootstrap.IFC4):
class TestGetQuantitiesIFC4(test.bootstrap.IFC4):
def test_getting_quantities_from_a_qto(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"x": 42})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"x": 42})
assert subject.get_quantities(qto.Quantities) == {"x": 42}
class TestGetPropertiesIFC4(test.bootstrap.IFC4):
def test_getting_no_properties_when_none_are_available(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
assert subject.get_properties(pset.HasProperties) == {}
def test_getting_single_properties_from_a_list_of_properties(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="name")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"a": "b"})
assert subject.get_properties(pset.HasProperties) == {"a": "b"}
def test_getting_complex_properties_from_a_list_of_properties(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="pset")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="pset")
complex_property = self.file.createIfcComplexProperty(Name="prop", UsageName="usage_name")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=complex_property, properties={"a": "b"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=complex_property, properties={"a": "b"})
pset.HasProperties = [complex_property]
assert subject.get_properties(pset.HasProperties) == {
"prop": {
@@ -246,68 +262,68 @@ class TestGetPropertiesIFC4(test.bootstrap.IFC4):
class TestGetPredefinedTypeIFC4(test.bootstrap.IFC4):
def test_getting_an_element_predefined_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.PredefinedType = "PARTITIONING"
assert subject.get_predefined_type(element) == "PARTITIONING"
def test_getting_an_element_userdefined_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.PredefinedType = "USERDEFINED"
element.ObjectType = "FOOBAR"
assert subject.get_predefined_type(element) == "FOOBAR"
def test_getting_an_element_type_without_a_predefined_type_attribute(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcAnnotation")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcAnnotation")
element.ObjectType = "FOOBAR"
assert subject.get_predefined_type(element) == "FOOBAR"
def test_getting_an_inherited_predefined_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
element_type.PredefinedType = "PARTITIONING"
assert subject.get_predefined_type(element) == "PARTITIONING"
def test_getting_an_inherited_userdefined_type_for_an_element_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
element_type.PredefinedType = "USERDEFINED"
element_type.ElementType = "FOOBAR"
assert subject.get_predefined_type(element) == "FOOBAR"
def test_getting_an_overriden_predefined_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
element_type.PredefinedType = "NOTDEFINED"
element.PredefinedType = "PARTITIONING"
assert subject.get_predefined_type(element) == "PARTITIONING"
def test_getting_an_inherited_userdefined_type_for_a_process_type(self):
- element = ifcopenshell.api.run("sequence.add_task", self.file)
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTaskType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.sequence.add_task(self.file)
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTaskType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
element_type.PredefinedType = "USERDEFINED"
element_type.ProcessType = "FOOBAR"
assert subject.get_predefined_type(element) == "FOOBAR"
def test_getting_an_element_type_predefined_type(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
element_type.PredefinedType = "PARTITIONING"
assert subject.get_predefined_type(element_type) == "PARTITIONING"
def test_getting_an_element_type_null_predefined_type(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
element_type.PredefinedType = "NOTDEFINED"
assert subject.get_predefined_type(element_type) == "NOTDEFINED"
class TestGetTypeIFC4(test.bootstrap.IFC4):
def test_getting_the_type_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
assert subject.get_type(element) == element_type
assert subject.get_type(element_type) == element_type
@@ -318,9 +334,9 @@ class TestGetTypeIFC2X3(test.bootstrap.IFC2X3, TestGetTypeIFC4):
class TestGetTypes(test.bootstrap.IFC4):
def test_getting_the_type_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
assert subject.get_types(element_type) == (element,)
@@ -330,7 +346,7 @@ class TestGetTypesIFC2X3(test.bootstrap.IFC2X3, TestGetTypes):
class TestGetShapeAspects(test.bootstrap.IFC4):
def test_getting_the_shape_aspects_of_a_product_type(self):
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
shape_aspect = self.file.createIfcShapeAspect()
representation_map = self.file.createIfcRepresentationMap()
element_type.RepresentationMaps = (representation_map,)
@@ -338,7 +354,7 @@ class TestGetShapeAspects(test.bootstrap.IFC4):
assert tuple(subject.get_shape_aspects(element_type)) == (shape_aspect,)
def test_getting_the_shape_aspects_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
shape_aspect = self.file.createIfcShapeAspect()
product_shape = self.file.createIfcProductDefinitionShape()
element.Representation = product_shape
@@ -348,105 +364,104 @@ class TestGetShapeAspects(test.bootstrap.IFC4):
class TestGetMaterial(test.bootstrap.IFC4):
def test_getting_the_material_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
assert subject.get_material(element) == material
def test_getting_a_material_list_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialList", material=material
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialList", material=material
)
assert subject.get_material(element) == rel.RelatingMaterial
def test_getting_a_material_layer_set_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialLayerSet"
)
assert subject.get_material(element) == rel.RelatingMaterial
def test_getting_a_material_profile_set_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialProfileSet"
)
assert subject.get_material(element) == rel.RelatingMaterial
def test_getting_a_material_layer_set_usage_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialLayerSetUsage"
)
assert subject.get_material(element) == rel.RelatingMaterial
def test_getting_a_material_profile_set_usage_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialProfileSetUsage"
)
assert subject.get_material(element) == rel.RelatingMaterial
def test_getting_a_material_layer_set_indirectly_from_an_assigned_usage(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialLayerSetUsage"
)
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForLayerSet
def test_getting_a_material_profile_set_indirectly_from_an_assigned_usage(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- rel = ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ rel = ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialProfileSetUsage"
)
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForProfileSet
def test_getting_an_inherited_material_from_the_elements_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material)
assert subject.get_material(element) == material
def test_getting_an_overridden_material_from_the_elements_occurrence(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
assert subject.get_material(element) == material
def test_getting_direct_materials_without_checking_inheritance(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material)
assert subject.get_material(element, should_inherit=False) is None
class TestGetMaterials(test.bootstrap.IFC4):
def test_getting_the_materials_of_a_product(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
assert subject.get_materials(element) == [material]
class TestGetStyles(test.bootstrap.IFC4):
def test_getting_the_styles_of_a_product(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_styles(element) == []
- model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- body = ifcopenshell.api.run(
- "context.add_context",
+ model = ifcopenshell.api.context.add_context(self.file, context_type="Model")
+ body = ifcopenshell.api.context.add_context(
self.file,
context_type="Model",
context_identifier="Body",
@@ -454,12 +469,11 @@ class TestGetStyles(test.bootstrap.IFC4):
parent=model,
)
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
- style = ifcopenshell.api.run("style.add_style", self.file)
- ifcopenshell.api.run(
- "style.add_surface_style",
+ style = ifcopenshell.api.style.add_style(self.file)
+ ifcopenshell.api.style.add_surface_style(
self.file,
style=style,
ifc_class="IfcSurfaceStyleShading",
@@ -468,13 +482,12 @@ class TestGetStyles(test.bootstrap.IFC4):
"Transparency": 0.0, # 0 is opaque, 1 is transparent
},
)
- ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=body)
+ ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=body)
assert subject.get_styles(element) == [style]
- style2 = ifcopenshell.api.run("style.add_style", self.file)
- ifcopenshell.api.run(
- "style.add_surface_style",
+ style2 = ifcopenshell.api.style.add_style(self.file)
+ ifcopenshell.api.style.add_surface_style(
self.file,
style=style2,
ifc_class="IfcSurfaceStyleShading",
@@ -484,15 +497,15 @@ class TestGetStyles(test.bootstrap.IFC4):
},
)
- representation = ifcopenshell.api.run(
- "geometry.add_wall_representation", self.file, context=body, length=5, height=3, thickness=0.118
+ representation = ifcopenshell.api.geometry.add_wall_representation(
+ self.file, context=body, length=5, height=3, thickness=0.118
)
- ifcopenshell.api.run(
- "geometry.assign_representation", self.file, product=element, representation=representation
+ ifcopenshell.api.geometry.assign_representation(
+ self.file, product=element, representation=representation
)
- ifcopenshell.api.run(
- "style.assign_representation_styles", self.file, shape_representation=representation, styles=[style2]
+ ifcopenshell.api.style.assign_representation_styles(
+ self.file, shape_representation=representation, styles=[style2]
)
assert subject.get_styles(element) == [style, style2]
@@ -500,35 +513,35 @@ class TestGetStyles(test.bootstrap.IFC4):
class TestGetElementsByMaterial(test.bootstrap.IFC4):
def test_getting_elements_of_a_material(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
assert subject.get_elements_by_material(self.file, material) == {element}
def test_getting_elements_of_a_material_layer_set(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
- ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material_set)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
+ ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material_set)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
usage = self.file.by_type("IfcMaterialLayerSetUsage")[0]
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
assert subject.get_elements_by_material(self.file, material_set) == {element, element_type}
assert subject.get_elements_by_material(self.file, usage) == {element}
def test_getting_elements_of_a_material_profile_set(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
- ifcopenshell.api.run("material.add_profile", self.file, profile_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material_set)
- ifcopenshell.api.run(
- "material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
+ ifcopenshell.api.material.add_profile(self.file, profile_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[element_type], material=material_set)
+ ifcopenshell.api.material.assign_material(
+ self.file, products=[element], type="IfcMaterialProfileSetUsage"
)
usage = self.file.by_type("IfcMaterialProfileSetUsage")[0]
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
@@ -536,22 +549,22 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
assert subject.get_elements_by_material(self.file, usage) == {element}
def test_getting_elements_of_a_material_constituent_set(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, set_type="IfcMaterialConstituentSet"
)
- ifcopenshell.api.run("material.add_constituent", self.file, constituent_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
assert subject.get_elements_by_material(self.file, material) == {element}
assert subject.get_elements_by_material(self.file, material_set) == {element}
def test_getting_elements_of_a_material_list(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
- ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file)
+ material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
+ ifcopenshell.api.material.add_list_item(self.file, material_list=material_set, material=material)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
assert subject.get_elements_by_material(self.file, material) == {element}
assert subject.get_elements_by_material(self.file, material_set) == {element}
@@ -601,8 +614,8 @@ class TestGetElementsByStyle(test.bootstrap.IFC4):
def test_getting_elements_of_a_styled_material(self):
element = self.file.createIfcWall()
- material = ifcopenshell.api.run("material.add_material", self.file)
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ material = ifcopenshell.api.material.add_material(self.file)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
style = self.file.createIfcSurfaceStyle()
self.file.createIfcMaterialDefinitionRepresentation(
RepresentedMaterial=material,
@@ -645,85 +658,85 @@ class TestGetElementsByRepresentation(test.bootstrap.IFC4):
class TestGetElementsByLayer(test.bootstrap.IFC4):
def test_getting_the_elements_of_a_layer(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ layer = ifcopenshell.api.layer.add_layer(self.file)
representation = self.file.createIfcShapeRepresentation()
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
- ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=[representation], layer=layer)
assert list(subject.get_elements_by_layer(self.file, layer)) == [element]
class TestGetlayersIFC2X3(test.bootstrap.IFC2X3):
def test_getting_the_layer_of_a_product_item(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ layer = ifcopenshell.api.layer.add_layer(self.file)
item = self.file.createIfcExtrudedAreaSolid()
representation = self.file.createIfcShapeRepresentation(Items=[item])
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
- ifcopenshell.api.run("layer.assign_layer", self.file, items=[item], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=[item], layer=layer)
assert subject.get_layers(self.file, element) == [layer]
def test_getting_the_layer_of_a_type_product_item(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ layer = ifcopenshell.api.layer.add_layer(self.file)
item = self.file.createIfcExtrudedAreaSolid()
representation = self.file.createIfcShapeRepresentation(Items=[item])
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
- ifcopenshell.api.run("layer.assign_layer", self.file, items=[item], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=[item], layer=layer)
assert subject.get_layers(self.file, element) == [layer]
class TestGetlayers(test.bootstrap.IFC4, TestGetlayersIFC2X3):
def test_getting_the_layer_of_a_product_representation(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ layer = ifcopenshell.api.layer.add_layer(self.file)
representation = self.file.createIfcShapeRepresentation()
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
- ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=[representation], layer=layer)
assert subject.get_layers(self.file, element) == [layer]
def test_getting_the_layer_of_a_type_product_representation(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- layer = ifcopenshell.api.run("layer.add_layer", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ layer = ifcopenshell.api.layer.add_layer(self.file)
representation = self.file.createIfcShapeRepresentation()
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
- ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
+ ifcopenshell.api.layer.assign_layer(self.file, items=[representation], layer=layer)
assert subject.get_layers(self.file, element) == [layer]
class TestGetContainerIFC4(test.bootstrap.IFC4):
def test_getting_the_spatial_container_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=building)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=building)
assert subject.get_container(element) == building
def test_getting_an_indirect_spatial_container_of_an_element(self):
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=building)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=building)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert subject.get_container(subelement) == building
def test_getting_nothing_if_we_enforce_only_getting_direct_spatial_containers(self):
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=building)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=building)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert subject.get_container(subelement, should_get_direct=True) is None
class TestGetReferencedStructures(test.bootstrap.IFC4):
def test_getting_references_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_referenced_structures(element) == []
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.reference_structure", self.file, products=[element], relating_structure=building)
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.reference_structure(self.file, products=[element], relating_structure=building)
assert subject.get_referenced_structures(element) == [building]
- building2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.reference_structure", self.file, products=[element], relating_structure=building2)
+ building2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.reference_structure(self.file, products=[element], relating_structure=building2)
assert subject.get_referenced_structures(element) == [building, building2]
@@ -733,13 +746,13 @@ class TestGetReferencedStructuresIFC2X3(test.bootstrap.IFC2X3, TestGetReferenced
class TestGetStructureReferencedElements(test.bootstrap.IFC4):
def test_getting_references_of_an_element(self):
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
assert subject.get_structure_referenced_elements(building) == set()
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.reference_structure", self.file, products=[element], relating_structure=building)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(self.file, products=[element], relating_structure=building)
assert subject.get_structure_referenced_elements(building) == {element}
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("spatial.reference_structure", self.file, products=[element2], relating_structure=building)
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.spatial.reference_structure(self.file, products=[element2], relating_structure=building)
assert subject.get_structure_referenced_elements(building) == {element, element2}
@@ -749,21 +762,21 @@ class TestGetStructureReferencedElementsIFC2X3(test.bootstrap.IFC2X3, TestGetStr
class TestGetDecompositionIFC4(test.bootstrap.IFC4):
def test_getting_decomposed_subelements_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=building)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=building)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
results = subject.get_decomposition(building)
assert element in results
assert subelement in results
def test_getting_openings_and_fills_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
- subsubelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindow")
- ifcopenshell.api.run("void.add_opening", self.file, element=element, opening=subelement)
- ifcopenshell.api.run("void.add_filling", self.file, element=subsubelement, opening=subelement)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
+ subsubelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindow")
+ ifcopenshell.api.void.add_opening(self.file, element=element, opening=subelement)
+ ifcopenshell.api.void.add_filling(self.file, element=subsubelement, opening=subelement)
results = subject.get_decomposition(element)
assert subelement in results
assert subsubelement in results
@@ -771,13 +784,13 @@ class TestGetDecompositionIFC4(test.bootstrap.IFC4):
class TestGetGroupsIFC4(test.bootstrap.IFC4):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group1 = ifcopenshell.api.run("group.add_group", self.file)
- group2 = ifcopenshell.api.run("group.add_group", self.file)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group1 = ifcopenshell.api.group.add_group(self.file)
+ group2 = ifcopenshell.api.group.add_group(self.file)
# assign group for multiple elements
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group1)
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group2)
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group1)
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group2)
assert set(subject.get_groups(element)) == set([group1, group2])
@@ -788,17 +801,17 @@ class TestGetGroupsIFC2X3(test.bootstrap.IFC2X3, TestGetGroupsIFC4):
class TestGetAggregateIFC4(test.bootstrap.IFC4):
def test_getting_the_containing_aggregate_of_a_subelement(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcCovering")
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcCovering")
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
assert subject.get_aggregate(subelement) == element
class TestGetNestIFC4(test.bootstrap.IFC4):
def test_getting_the_nest_parent_of_an_element(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
- ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
+ ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
assert subject.get_nest(subelement) == element
@@ -812,13 +825,12 @@ class TestGetReferencedElements(test.bootstrap.IFC4):
# IfcExternallyDefinedSurfaceStyle
# IfcExternallyDefinedTextFont
def test_get_elements_referenced_by_classification_reference(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")]
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")]
if self.file.schema != "IFC2X3":
elements.append(self.file.create_entity("IfcCostValue"))
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- reference = ifcopenshell.api.run(
- "classification.add_reference",
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ reference = ifcopenshell.api.classification.add_reference(
self.file,
products=elements,
identification="X",
@@ -830,19 +842,19 @@ class TestGetReferencedElements(test.bootstrap.IFC4):
def test_get_elements_referenced_by_library_reference(self):
reference = self.file.createIfcLibraryReference()
elements = [
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall"),
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall"),
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall"),
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall"),
]
- ifcopenshell.api.run("library.assign_reference", self.file, reference=reference, products=elements)
+ ifcopenshell.api.library.assign_reference(self.file, reference=reference, products=elements)
assert subject.get_referenced_elements(reference) == set(elements)
def test_get_elements_referenced_by_document_reference(self):
- reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
+ reference = ifcopenshell.api.document.add_reference(self.file, information=None)
elements = [
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall"),
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall"),
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall"),
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall"),
]
- ifcopenshell.api.run("document.assign_document", self.file, document=reference, products=elements)
+ ifcopenshell.api.document.assign_document(self.file, document=reference, products=elements)
assert subject.get_referenced_elements(reference) == set(elements)
diff --git a/src/ifcopenshell-python/test/util/test_schema.py b/src/ifcopenshell-python/test/util/test_schema.py
index 470234235c..d814ecf7b5 100644
--- a/src/ifcopenshell-python/test/util/test_schema.py
+++ b/src/ifcopenshell-python/test/util/test_schema.py
@@ -16,17 +16,16 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.project
import ifcopenshell.util.schema as subject
class TestMigrator(test.bootstrap.IFC4):
def test_migrate_element_using_attribute_mapping_ifc4_ifc4x3(self):
- ifc4_file = ifcopenshell.api.run("project.create_file")
+ ifc4_file = ifcopenshell.api.project.create_file()
original_element = ifc4_file.createIfcWorkTime(Start="2024-01-01", Finish="2024-01-01")
- ifc4x3_file = ifcopenshell.api.run("project.create_file", version="IFC4X3")
+ ifc4x3_file = ifcopenshell.api.project.create_file(version="IFC4X3")
migrator = subject.Migrator()
for element in ifc4_file:
@@ -37,9 +36,9 @@ class TestMigrator(test.bootstrap.IFC4):
assert original_element.Finish == new_element.FinishDate
def test_migrate_element_using_attribute_mapping_ifc4x3_ifc4(self):
- ifc4x3_file = ifcopenshell.api.run("project.create_file", version="IFC4X3")
+ ifc4x3_file = ifcopenshell.api.project.create_file(version="IFC4X3")
original_element = ifc4x3_file.createIfcWorkTime(StartDate="2024-01-01", FinishDate="2024-01-01")
- ifc4_file = ifcopenshell.api.run("project.create_file")
+ ifc4_file = ifcopenshell.api.project.create_file()
migrator = subject.Migrator()
for element in ifc4x3_file:
@@ -50,9 +49,9 @@ class TestMigrator(test.bootstrap.IFC4):
assert original_element.FinishDate == new_element.Finish
def test_migrate_element_using_attribute_mapping_ifc2x3_ifc4(self):
- ifc2x3_file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
+ ifc2x3_file = ifcopenshell.api.project.create_file(version="IFC2X3")
original_element = ifc2x3_file.createIfcImageTexture(TextureType="SPECULAR")
- ifc4_file = ifcopenshell.api.run("project.create_file")
+ ifc4_file = ifcopenshell.api.project.create_file()
migrator = subject.Migrator()
for element in ifc2x3_file:
@@ -62,9 +61,9 @@ class TestMigrator(test.bootstrap.IFC4):
assert original_element.TextureType == new_element.Mode
def test_migrate_element_using_attribute_mapping_ifc4_ifc2x3(self):
- ifc4_file = ifcopenshell.api.run("project.create_file")
+ ifc4_file = ifcopenshell.api.project.create_file()
original_element = ifc4_file.createIfcImageTexture(Mode="SPECULAR")
- ifc2x3_file = ifcopenshell.api.run("project.create_file", version="IFC2X3")
+ ifc2x3_file = ifcopenshell.api.project.create_file(version="IFC2X3")
migrator = subject.Migrator()
for element in ifc4_file:
diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py
index 4dcc177bb7..51ce7f3dea 100644
--- a/src/ifcopenshell-python/test/util/test_selector.py
+++ b/src/ifcopenshell-python/test/util/test_selector.py
@@ -18,7 +18,16 @@
import pytest
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.spatial
+import ifcopenshell.api.root
+import ifcopenshell.api.unit
+import ifcopenshell.api.classification
+import ifcopenshell.api.pset
+import ifcopenshell.api.type
+import ifcopenshell.api.material
+import ifcopenshell.api.geometry
+import ifcopenshell.api.aggregate
+import ifcopenshell.api.group
import ifcopenshell.util.selector as subject
import ifcopenshell.util.placement
import ifcopenshell.util.pset
@@ -64,28 +73,28 @@ class TestFormat:
class TestGetElementValue(test.bootstrap.IFC4):
def test_selecting_an_elements_class_or_id_using_a_query(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_element_value(element, "class") == "IfcWall"
assert subject.get_element_value(element, "id") == element.id()
def test_selecting_an_elements_value_using_a_query(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Name = "Foobar"
assert subject.get_element_value(element, "Name") == "Foobar"
def test_selecting_using_a_multiple_key_query(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- material2 = ifcopenshell.api.run("material.add_material", self.file, name="CON02")
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, name="FOO", set_type="IfcMaterialLayerSet"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, name="FOO", set_type="IfcMaterialLayerSet"
)
- layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
+ layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
layer.Name = "L1"
- layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
+ layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
layer.Name = "L2"
- ifcopenshell.api.run("material.edit_layer", self.file, layer=layer, attributes={"LayerThickness": 13})
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ ifcopenshell.api.material.edit_layer(self.file, layer=layer, attributes={"LayerThickness": 13})
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
assert subject.get_element_value(element, "material.MaterialLayers.Name") == ["L1", "L2"]
# Allow to use "item" to generically select an item in a material set
assert subject.get_element_value(element, "material.item.Name") == ["L1", "L2"]
@@ -97,45 +106,45 @@ class TestGetElementValue(test.bootstrap.IFC4):
assert subject.get_element_value(element, "mat.i.Name") == ["L1", "L2"]
def test_selecting_a_query_that_fails_silently(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.get_element_value(element, "material.item.Name.0") is None
def test_selecting_a_list_item_that_fails_silently(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- material2 = ifcopenshell.api.run("material.add_material", self.file, name="CON02")
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, name="FOO", set_type="IfcMaterialLayerSet"
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ material2 = ifcopenshell.api.material.add_material(self.file, name="CON02")
+ material_set = ifcopenshell.api.material.add_material_set(
+ self.file, name="FOO", set_type="IfcMaterialLayerSet"
)
- layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
+ layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
layer.Name = "L1"
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
assert subject.get_element_value(element, "material.item.Name.0") == "L1"
assert subject.get_element_value(element, "material.item.Name.1") is None
def test_selecting_a_pset(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
assert subject.get_element_value(element, "Foobar.Foo") == "Bar"
assert subject.get_element_value(element, "Foobar./F.*/") == "Bar"
assert subject.get_element_value(element, "/Foo.*/./F.*/") == "Bar"
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Baz": 123})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Baz": 123})
assert subject.get_element_value(element, "/Foo.*/./B.*/") == 123
assert subject.get_element_value(element, "/Foo.*/./.*/") == ["Bar", 123]
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Bay": 123.3})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Bay": 123.3})
assert subject.get_element_value(element, "/Foo.*/./B.*/") == [123, 123.3]
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["New"]})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["New"]})
assert subject.get_element_value(element, "/Pset_.*Common/.Status") == ["New"]
assert subject.get_element_value(element, "/Pset_.*Common/.Status.0") == "New"
class TestFilterElements(test.bootstrap.IFC4):
def test_selecting_by_globalid(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
guid1 = element.GlobalId
guid2 = element2.GlobalId
assert subject.filter_elements(self.file, f"{guid1}") == {element}
@@ -144,18 +153,18 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, f"IfcElement, ! {guid2}") == {element}
def test_selecting_by_class(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Name = "Foo"
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
assert subject.filter_elements(self.file, "IfcWall") == {element}
assert subject.filter_elements(self.file, "IfcElement, ! IfcWall") == {element2}
def test_selecting_by_attribute(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Name = "Foo"
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element2.Name = "Bar"
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
assert subject.filter_elements(self.file, "IfcWall, Name=Foo") == {element}
element.Name = 'Foo\'s "quoted" name...'
assert subject.filter_elements(self.file, 'IfcWall, Name="Foo\'s \\"quoted\\" name..."') == {element}
@@ -165,15 +174,15 @@ class TestFilterElements(test.bootstrap.IFC4):
element.Description = "Foobar"
assert subject.filter_elements(self.file, "IfcWall, Name=Foo, Description=Foobar") == {element}
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
element_type.PredefinedType = "SOLIDWALL"
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
assert subject.filter_elements(self.file, "IfcWall, PredefinedType=SOLIDWALL") == {element}
def test_selecting_by_type(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
+ ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
assert subject.filter_elements(self.file, "IfcWall, type=Foo") == set()
element_type.Name = "Foo"
assert subject.filter_elements(self.file, "IfcWall, type=Foo") == {element}
@@ -181,54 +190,53 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, "IfcWall, type=/Fo.*/") == {element}
def test_selecting_by_material(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.filter_elements(self.file, "IfcWall, material=NULL") == {element, element2}
- material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
- ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
+ material = ifcopenshell.api.material.add_material(self.file, name="CON01")
+ ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
assert subject.filter_elements(self.file, "IfcWall, material=CON01") == {element}
assert subject.filter_elements(self.file, "IfcWall, material!=CON01") == {element2}
def test_selecting_by_property(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
assert subject.filter_elements(self.file, "IfcWall, Foobar.Foo=Bar") == {element}
assert subject.filter_elements(self.file, 'IfcWall, Foobar."Foo"=Bar') == {element}
assert subject.filter_elements(self.file, "IfcWall, Foobar./Fo.*/=Bar") == {element}
assert subject.filter_elements(self.file, "IfcWall, Foobar./Fo.*/!=Bar") == {element2}
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Bar": False})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Bar": False})
assert subject.filter_elements(self.file, "IfcWall, Foobar.Bar=FALSE") == {element}
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Baz": 123})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Baz": 123})
assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz=123") == {element}
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Bay": 123.3})
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["New"]})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Bay": 123.3})
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["New"]})
assert subject.filter_elements(self.file, "IfcWall, Pset_WallCommon.Status=New") == {element}
def test_selecting_by_property_with_comparisons(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Baz": 123})
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Baz": 123})
assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz>100") == {element}
assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz<100") == set()
assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz>=100") == {element}
assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz<=100") == set()
- ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
+ ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
assert subject.filter_elements(self.file, "IfcWall, Foobar.Foo*=ar") == {element}
assert subject.filter_elements(self.file, "IfcWall, Foobar.Foo!*=ar") == {element2}
assert subject.filter_elements(self.file, "IfcWall, Foobar.Foo*=Foo") == set()
def test_selecting_by_classification(self):
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
assert subject.filter_elements(self.file, "IfcWall, classification=NULL") == {element, element2}
- result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
- ifcopenshell.api.run(
- "classification.add_reference",
+ result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
+ ifcopenshell.api.classification.add_reference(
self.file,
products=[element],
identification="X",
@@ -241,17 +249,17 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, "IfcWall, classification!=X") == {element2}
def test_selecting_by_location(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- space = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace", name="Space")
- storey = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey", name="G")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding", name="Building")
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject", name="Project")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=space)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element2], relating_structure=storey)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[space], relating_object=storey)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[storey], relating_object=building)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[building], relating_object=project)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ space = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace", name="Space")
+ storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey", name="G")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding", name="Building")
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject", name="Project")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=space)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element2], relating_structure=storey)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[space], relating_object=storey)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[building], relating_object=project)
assert subject.filter_elements(self.file, "IfcWall, location=NULL") == set()
assert subject.filter_elements(self.file, "IfcWall, location=Space") == {element}
assert subject.filter_elements(self.file, "IfcWall, location=G") == {element, element2}
@@ -259,36 +267,36 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, "IfcWall, location!=Space") == {element2}
def test_selecting_by_group(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- group = ifcopenshell.api.run("group.add_group", self.file, name="Foo")
- ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ group = ifcopenshell.api.group.add_group(self.file, name="Foo")
+ ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
assert subject.filter_elements(self.file, "IfcWall, group=Foo") == {element}
assert subject.filter_elements(self.file, "IfcWall, group!=Foo") == {element2}
def test_selecting_by_parent(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Element1")
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Element2")
- element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Element3")
- space = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace", name="Space")
- storey = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey", name="G")
- building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding", name="Building")
- project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject", name="Project")
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=space)
- ifcopenshell.api.run("spatial.assign_container", self.file, products=[element2], relating_structure=storey)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[element3], relating_object=element2)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[space], relating_object=storey)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[storey], relating_object=building)
- ifcopenshell.api.run("aggregate.assign_object", self.file, products=[building], relating_object=project)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall", name="Element1")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall", name="Element2")
+ element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall", name="Element3")
+ space = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace", name="Space")
+ storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey", name="G")
+ building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding", name="Building")
+ project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject", name="Project")
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=space)
+ ifcopenshell.api.spatial.assign_container(self.file, products=[element2], relating_structure=storey)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[element3], relating_object=element2)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[space], relating_object=storey)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
+ ifcopenshell.api.aggregate.assign_object(self.file, products=[building], relating_object=project)
assert subject.filter_elements(self.file, "IfcWall, parent=Project") == {element, element2, element3}
assert subject.filter_elements(self.file, "IfcWall, parent=Space") == {element}
assert subject.filter_elements(self.file, "IfcWall, parent=G") == {element, element2, element3}
assert subject.filter_elements(self.file, "IfcWall, parent=Element2") == {element3}
def test_selecting_multiple_filter_groups(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element.Name = "Foo"
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
element2.Name = "Bar"
assert subject.filter_elements(self.file, "IfcWall + IfcSlab") == {element, element2}
assert subject.filter_elements(self.file, "IfcWall, IfcSlab, Name=Foo") == {element}
@@ -296,9 +304,9 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, "IfcWall, Name=Foo + IfcSlab, Name=Bar") == {element, element2}
def test_using_elements_argument(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
- door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
+ door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
elements = {wall, slab}
results = subject.filter_elements(self.file, "IfcWall", {wall, slab})
assert results != elements
@@ -307,7 +315,7 @@ class TestFilterElements(test.bootstrap.IFC4):
assert subject.filter_elements(self.file, "IfcWall, IfcSlab", elements) == {wall, slab}
def test_editing_in_place(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
original_set = {wall}
new_set = subject.filter_elements(self.file, "IfcWall", original_set, edit_in_place=True)
assert new_set == original_set == {wall}
@@ -315,20 +323,20 @@ class TestFilterElements(test.bootstrap.IFC4):
class TestSetElementValue(test.bootstrap.IFC4):
def test_set_xyz_coordinates(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- ifcopenshell.api.run("unit.assign_unit", self.file)
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ ifcopenshell.api.unit.assign_unit(self.file)
items = list(zip("xyz", ("5", "10", "15")))
matrix = np.eye(4)
matrix[:, 3] = (5, 10, 15, 1)
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element, is_si=False)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
+ ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, is_si=False)
for coord, value in items:
subject.set_element_value(self.file, element, coord, value)
assert np.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
- element_without_placement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ element_without_placement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
for coord, value in items:
subject.set_element_value(self.file, element_without_placement, coord, value)
assert np.array_equal(
diff --git a/src/ifcopenshell-python/test/util/test_system.py b/src/ifcopenshell-python/test/util/test_system.py
index 3035f07da6..2796c3c3d2 100644
--- a/src/ifcopenshell-python/test/util/test_system.py
+++ b/src/ifcopenshell-python/test/util/test_system.py
@@ -19,6 +19,8 @@
import pytest
import test.bootstrap
import ifcopenshell.api
+import ifcopenshell.api.root
+import ifcopenshell.api.system
import ifcopenshell.util.system as subject
@@ -34,31 +36,29 @@ class TestIsAssignable(test.bootstrap.IFC4):
class TestGetSystemElements(test.bootstrap.IFC4):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=system)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ ifcopenshell.api.system.assign_system(self.file, products=[element], system=system)
assert subject.get_system_elements(system) == [element]
class TestGetElementSystems(test.bootstrap.IFC4):
def test_run(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
- system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
- ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=system)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
+ system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
+ ifcopenshell.api.system.assign_system(self.file, products=[element], system=system)
assert subject.get_element_systems(element) == [system]
def test_do_not_get_non_services_groups(self):
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
- ifcopenshell.api.run(
- "system.assign_system",
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
+ ifcopenshell.api.system.assign_system(
self.file,
products=[element],
system=self.file.createIfcGroup(),
)
for not_assignable_system_class in ("IfcZone", "IfcStructuralAnalysisModel"):
with pytest.raises(TypeError):
- ifcopenshell.api.run(
- "system.assign_system",
+ ifcopenshell.api.system.assign_system(
self.file,
products=[element],
system=self.file.create_entity(not_assignable_system_class),
@@ -69,8 +69,8 @@ class TestGetElementSystems(test.bootstrap.IFC4):
class TestGetPorts(test.bootstrap.IFC4):
def test_run(self):
port = self.file.createIfcDistributionPort()
- element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
+ element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
assert subject.get_ports(element) == [port]
@@ -80,30 +80,30 @@ class TestGetPortsIFC2X3(test.bootstrap.IFC2X3, TestGetPorts):
class TestGetConnectedPort(test.bootstrap.IFC4):
def test_run(self):
- port1 = ifcopenshell.api.run("system.add_port", self.file)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2)
+ port1 = ifcopenshell.api.system.add_port(self.file)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2)
assert subject.get_connected_port(port1) == port2
assert subject.get_connected_port(port2) == port1
class TestGetConnectedToFrom(test.bootstrap.IFC4):
def test_run(self):
- port1 = ifcopenshell.api.run("system.add_port", self.file)
- element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element1, port=port1)
+ port1 = ifcopenshell.api.system.add_port(self.file)
+ element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element1, port=port1)
- port2 = ifcopenshell.api.run("system.add_port", self.file)
- element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
- ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
+ port2 = ifcopenshell.api.system.add_port(self.file)
+ element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
+ ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
- ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SOURCE")
+ ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SOURCE")
assert subject.get_connected_to(element1) == [element2]
assert subject.get_connected_from(element1) == []
assert subject.get_connected_to(element2) == []
assert subject.get_connected_from(element2) == [element1]
- ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SINK")
+ ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SINK")
assert subject.get_connected_to(element1) == []
assert subject.get_connected_from(element1) == [element2]
assert subject.get_connected_to(element2) == [element1]
diff --git a/src/ifcopenshell-python/test/util/test_unit.py b/src/ifcopenshell-python/test/util/test_unit.py
index 0852019976..59b3c3371b 100644
--- a/src/ifcopenshell-python/test/util/test_unit.py
+++ b/src/ifcopenshell-python/test/util/test_unit.py
@@ -17,7 +17,8 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
-import ifcopenshell.api
+import ifcopenshell.api.unit
+import ifcopenshell.api.root
import ifcopenshell.util.unit as subject
from math import pi
@@ -34,15 +35,15 @@ class TestConvert(test.bootstrap.IFC4):
class TestCalculateUnitScale(test.bootstrap.IFC4):
def test_prefix_and_conversion_based_units_are_considered(self):
- ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- length = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="foot")
+ ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
+ length = ifcopenshell.api.unit.add_conversion_based_unit(self.file, name="foot")
length.ConversionFactor.UnitComponent.Prefix = "MILLI"
- ifcopenshell.api.run("unit.assign_unit", self.file, units=[length])
+ ifcopenshell.api.unit.assign_unit(self.file, units=[length])
assert subject.calculate_unit_scale(self.file) == 0.3048 * 0.001
- angle = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="degree")
+ angle = ifcopenshell.api.unit.add_conversion_based_unit(self.file, name="degree")
angle.ConversionFactor.UnitComponent.Prefix = "MILLI"
- ifcopenshell.api.run("unit.assign_unit", self.file, units=[angle])
+ ifcopenshell.api.unit.assign_unit(self.file, units=[angle])
assert subject.calculate_unit_scale(self.file, "PLANEANGLEUNIT") == pi / 180 * 0.001