mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
descriptive error for missing user or application in ifc2x3 #4340
This commit is contained in:
@@ -106,16 +106,26 @@ class Usecase:
|
|||||||
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
||||||
if self.file.schema != "IFC2X3" and not application:
|
if self.file.schema != "IFC2X3" and not application:
|
||||||
return
|
return
|
||||||
return self.file.create_entity(
|
try:
|
||||||
"IfcOwnerHistory",
|
return self.file.create_entity(
|
||||||
**{
|
"IfcOwnerHistory",
|
||||||
"OwningUser": user,
|
**{
|
||||||
"OwningApplication": application,
|
"OwningUser": user,
|
||||||
"State": "READWRITE",
|
"OwningApplication": application,
|
||||||
"ChangeAction": "ADDED",
|
"State": "READWRITE",
|
||||||
"LastModifiedDate": int(time.time()),
|
"ChangeAction": "ADDED",
|
||||||
"LastModifyingUser": user,
|
"LastModifiedDate": int(time.time()),
|
||||||
"LastModifyingApplication": application,
|
"LastModifyingUser": user,
|
||||||
"CreationDate": int(time.time()),
|
"LastModifyingApplication": application,
|
||||||
},
|
"CreationDate": int(time.time()),
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
# clarification message because error may come out of blue for users
|
||||||
|
# first time they try to create_entity in IFC2X3
|
||||||
|
if self.file.schema == "IFC2X3" and (application is None or user is None):
|
||||||
|
raise Exception(
|
||||||
|
"In IFC2X3 setting up owner history mandatory but it cannot be setup because either user or application is not set. "
|
||||||
|
"See an example in the owner.create_owner_history documentation."
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|||||||
Reference in New Issue
Block a user