2021-01-26 13:56:38 +11:00
|
|
|
import time
|
|
|
|
|
import ifcopenshell
|
2021-03-25 11:42:12 +11:00
|
|
|
import ifcopenshell.api.owner.settings
|
2021-01-26 13:56:38 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Usecase:
|
2021-03-27 19:14:32 +11:00
|
|
|
def __init__(self, file, **settings):
|
2021-01-26 13:56:38 +11:00
|
|
|
self.file = file
|
2021-03-29 16:53:11 +11:00
|
|
|
self.settings = {}
|
2021-01-26 13:56:38 +11:00
|
|
|
for key, value in settings.items():
|
|
|
|
|
self.settings[key] = value
|
|
|
|
|
|
|
|
|
|
def execute(self):
|
2021-10-01 11:05:35 +10:00
|
|
|
user = ifcopenshell.api.owner.settings.get_user(self.file)
|
2021-07-04 19:57:09 +10:00
|
|
|
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
2021-03-25 11:42:12 +11:00
|
|
|
if self.file.schema != "IFC2X3":
|
2021-10-01 11:05:35 +10:00
|
|
|
if not user or not application:
|
2021-03-25 11:42:12 +11:00
|
|
|
return
|
2021-01-26 13:56:38 +11:00
|
|
|
return self.file.create_entity(
|
|
|
|
|
"IfcOwnerHistory",
|
|
|
|
|
**{
|
|
|
|
|
"OwningUser": user,
|
|
|
|
|
"OwningApplication": application,
|
|
|
|
|
"State": "READWRITE",
|
2021-03-25 16:32:43 +11:00
|
|
|
"ChangeAction": "ADDED",
|
2021-01-26 13:56:38 +11:00
|
|
|
"LastModifiedDate": int(time.time()),
|
|
|
|
|
"LastModifyingUser": user,
|
|
|
|
|
"LastModifyingApplication": application,
|
|
|
|
|
"CreationDate": int(time.time()),
|
|
|
|
|
},
|
|
|
|
|
)
|