mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
from typing import Union
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
@@ -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 {}}
|
||||
|
||||
@@ -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 {}}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user