mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 19:30:25 +00:00
Write docs for owner API module
This commit is contained in:
@@ -24,11 +24,39 @@ import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
def __init__(self, file, element=None):
|
||||
"""Updates the owner that is assigned to an object
|
||||
|
||||
This ensures that the owner is tracked to have modified the object last,
|
||||
including the time when the change occured. See
|
||||
ifcopenshell.api.owner.create_owner_history for details.
|
||||
|
||||
:param element: The IfcRoot element to update the ownership details on
|
||||
when a change is made.
|
||||
:type element: ifcopenshell.entity_instance.entity_instance
|
||||
:return: The updated IfcOwnerHistory element.
|
||||
:rtype: ifcopenshell.entity_instance.entity_instance
|
||||
|
||||
Example::
|
||||
|
||||
# See ifcopenshell.api.owner.create_owner_history for setup
|
||||
# [ ... example setup code ... ]
|
||||
|
||||
# We've finished our ownership setup. Now let's start our script and
|
||||
# create a space. Notice we don't actually call
|
||||
# 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")
|
||||
|
||||
# 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"})
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
self.settings = {"element": element}
|
||||
|
||||
def execute(self):
|
||||
if not hasattr(self.settings["element"], "OwnerHistory"):
|
||||
|
||||
Reference in New Issue
Block a user