mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ def assign_product(
|
||||
|
||||
.. code:: python
|
||||
|
||||
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.run("drawing.assign_product", model,
|
||||
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.drawing.assign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
"""
|
||||
settings = {
|
||||
@@ -99,13 +99,13 @@ def assign_product(
|
||||
related_objects = list(referenced_by.RelatedObjects)
|
||||
related_objects.append(settings["related_object"])
|
||||
referenced_by.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": referenced_by})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": referenced_by})
|
||||
else:
|
||||
referenced_by = file.create_entity(
|
||||
"IfcRelAssignsToProduct",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingProduct": settings["relating_product"],
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ def edit_text_literal(
|
||||
.. code:: python
|
||||
|
||||
text = model.createIfcTextLiteral()
|
||||
ifcopenshell.api.run("drawing.edit_text_literal", model,
|
||||
ifcopenshell.api.drawing.edit_text_literal(model,
|
||||
text_literal=text, attributes={"Literal": "MY ANNOTATION"})
|
||||
"""
|
||||
settings = {"text_literal": text_literal, "attributes": attributes or {}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ def unassign_product(
|
||||
|
||||
.. code:: python
|
||||
|
||||
furniture = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.run("drawing.assign_product", model,
|
||||
furniture = ifcopenshell.api.root.create_entity(model, ifc_class="IfcFurniture")
|
||||
annotation = ifcopenshell.api.root.create_entity(model, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.drawing.assign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
|
||||
# Let's change our mind and remove the relationship
|
||||
ifcopenshell.api.run("drawing.unassign_product", model,
|
||||
ifcopenshell.api.drawing.unassign_product(model,
|
||||
relating_product=furniture, related_object=annotation)
|
||||
"""
|
||||
settings = {
|
||||
@@ -71,4 +71,4 @@ def unassign_product(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, element=rel)
|
||||
|
||||
Reference in New Issue
Block a user