Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -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],
)
@@ -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}
@@ -17,7 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.owner
import ifcopenshell.guid
import ifcopenshell.util.element
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
@@ -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"})
@@ -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}
@@ -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,):
@@ -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":
@@ -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
@@ -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)