Fix #4340. Indicate user needs to setup IFC2X3 user/app when using API directly.

This commit is contained in:
Dion Moult
2024-03-01 19:46:50 +11:00
parent 4f3397a04e
commit 2bede1cdf0
2 changed files with 26 additions and 26 deletions
@@ -30,7 +30,13 @@ def get_application(ifc):
:return: The IfcApplication with metadata of the authoring software.
:rtype: ifcopenshell.entity_instance.entity_instance
"""
return (ifc.by_type("IfcApplication") or [None])[0]
app = ifc.by_type("IfcApplication")
if not app and ifc.schema == "IFC2X3":
raise Exception(
"Please create an application to continue. See the owner.create_owner_history docs for more info."
"https://blenderbim.org/docs-python/autoapi/ifcopenshell/api/owner/create_owner_history/index.html"
)
return (app or [None])[0]
def get_user(ifc):
@@ -44,7 +50,13 @@ def get_user(ifc):
:return: The IfcPersonAndOrganization with metadata of the authoring user.
:rtype: ifcopenshell.entity_instance.entity_instance
"""
return (ifc.by_type("IfcPersonAndOrganization") or [None])[0]
pao = ifc.by_type("IfcPersonAndOrganization")
if not pao and ifc.schema == "IFC2X3":
raise Exception(
"Please create a user to continue. See the owner.create_owner_history docs for more info."
"https://blenderbim.org/docs-python/autoapi/ifcopenshell/api/owner/create_owner_history/index.html"
)
return (pao or [None])[0]
get_application_factory = get_application