mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Finish decoupling ownership history code from Blender
This commit is contained in:
@@ -6,18 +6,18 @@ import ifcopenshell.api.owner.settings
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = ifcopenshell.api.owner.settings.settings
|
||||
self.settings = {}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
self.settings["person"] = ifcopenshell.api.owner.settings.get_person()
|
||||
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation()
|
||||
self.settings["person"] = ifcopenshell.api.owner.settings.get_person(self.file)
|
||||
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation(self.file)
|
||||
if self.file.schema != "IFC2X3":
|
||||
if not self.settings["person"] or not self.settings["organisation"]:
|
||||
return
|
||||
user = self.get_user()
|
||||
application = self.get_application()
|
||||
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
||||
return self.file.create_entity(
|
||||
"IfcOwnerHistory",
|
||||
**{
|
||||
@@ -43,58 +43,3 @@ class Usecase:
|
||||
"IfcPersonAndOrganization",
|
||||
**{"ThePerson": self.settings["person"], "TheOrganization": self.settings["organisation"]},
|
||||
)
|
||||
|
||||
def get_application(self):
|
||||
for element in self.file.by_type("IfcApplication"):
|
||||
if element.ApplicationIdentifier == self.settings["ApplicationIdentifier"]:
|
||||
return element
|
||||
return self.file.create_entity(
|
||||
"IfcApplication",
|
||||
**{
|
||||
"ApplicationDeveloper": self.get_application_organisation(),
|
||||
"Version": self.settings["Version"],
|
||||
"ApplicationFullName": self.settings["ApplicationFullName"],
|
||||
"ApplicationIdentifier": self.settings["ApplicationIdentifier"],
|
||||
},
|
||||
)
|
||||
|
||||
def get_application_organisation(self):
|
||||
return self.file.create_entity(
|
||||
"IfcOrganization",
|
||||
**{
|
||||
"Name": "IfcOpenShell",
|
||||
"Description": "IfcOpenShell is an open source (LGPL) software library that helps users and software developers to work with the IFC file format.",
|
||||
"Roles": [
|
||||
self.file.create_entity("IfcActorRole", **{"Role": "USERDEFINED", "UserDefinedRole": "CONTRIBUTOR"})
|
||||
],
|
||||
"Addresses": [
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "WEBPAGE",
|
||||
"Description": "The main webpage of the software collection.",
|
||||
"WWWHomePageURL": "https://ifcopenshell.org",
|
||||
},
|
||||
),
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "WEBPAGE",
|
||||
"Description": "The BlenderBIM Add-on webpage of the software collection.",
|
||||
"WWWHomePageURL": "https://blenderbim.org",
|
||||
},
|
||||
),
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "REPOSITORY",
|
||||
"Description": "The source code repository of the software collection.",
|
||||
"WWWHomePageURL": "https://github.com/IfcOpenShell/IfcOpenShell.git",
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
def get_person():
|
||||
def get_person(ifc):
|
||||
pass
|
||||
|
||||
|
||||
def get_organisation():
|
||||
def get_organisation(ifc):
|
||||
pass
|
||||
|
||||
|
||||
settings = {
|
||||
"ApplicationIdentifier": "",
|
||||
"ApplicationFullName": "",
|
||||
"Version": "",
|
||||
}
|
||||
def get_application(ifc):
|
||||
pass
|
||||
|
||||
@@ -6,13 +6,13 @@ import ifcopenshell.api
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = ifcopenshell.api.owner.settings.settings
|
||||
self.settings = {}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
self.settings["person"] = ifcopenshell.api.owner.settings.get_person()
|
||||
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation()
|
||||
self.settings["person"] = ifcopenshell.api.owner.settings.get_person(self.file)
|
||||
self.settings["organisation"] = ifcopenshell.api.owner.settings.get_organisation(self.file)
|
||||
if not self.settings["element"].OwnerHistory:
|
||||
self.settings["element"].OwnerHistory = ifcopenshell.api.run(
|
||||
"owner.create_owner_history", self.file, **self.settings
|
||||
@@ -24,7 +24,7 @@ class Usecase:
|
||||
for i, attribute in enumerate(old_history):
|
||||
self.settings["element"].OwnerHistory[i] = attribute
|
||||
user = self.get_user()
|
||||
application = self.get_application()
|
||||
application = ifcopenshell.api.owner.settings.get_application(self.file)
|
||||
self.settings["element"].OwnerHistory.ChangeAction = "MODIFIED"
|
||||
self.settings["element"].OwnerHistory.LastModifiedDate = int(time.time())
|
||||
self.settings["element"].OwnerHistory.LastModifyingUser = user
|
||||
@@ -42,58 +42,3 @@ class Usecase:
|
||||
"IfcPersonAndOrganization",
|
||||
**{"ThePerson": self.settings["person"], "TheOrganization": self.settings["organisation"]},
|
||||
)
|
||||
|
||||
def get_application(self):
|
||||
for element in self.file.by_type("IfcApplication"):
|
||||
if element.ApplicationIdentifier == self.settings["ApplicationIdentifier"]:
|
||||
return element
|
||||
return self.file.create_entity(
|
||||
"IfcApplication",
|
||||
**{
|
||||
"ApplicationDeveloper": self.get_application_organisation(),
|
||||
"Version": self.settings["Version"],
|
||||
"ApplicationFullName": self.settings["ApplicationFullName"],
|
||||
"ApplicationIdentifier": self.settings["ApplicationIdentifier"],
|
||||
},
|
||||
)
|
||||
|
||||
def get_application_organisation(self):
|
||||
return self.file.create_entity(
|
||||
"IfcOrganization",
|
||||
**{
|
||||
"Name": "IfcOpenShell",
|
||||
"Description": "IfcOpenShell is an open source (LGPL) software library that helps users and software developers to work with the IFC file format.",
|
||||
"Roles": [
|
||||
self.file.create_entity("IfcActorRole", **{"Role": "USERDEFINED", "UserDefinedRole": "CONTRIBUTOR"})
|
||||
],
|
||||
"Addresses": [
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "WEBPAGE",
|
||||
"Description": "The main webpage of the software collection.",
|
||||
"WWWHomePageURL": "https://ifcopenshell.org",
|
||||
},
|
||||
),
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "WEBPAGE",
|
||||
"Description": "The BlenderBIM Add-on webpage of the software collection.",
|
||||
"WWWHomePageURL": "https://blenderbim.org",
|
||||
},
|
||||
),
|
||||
self.file.create_entity(
|
||||
"IfcTelecomAddress",
|
||||
**{
|
||||
"Purpose": "USERDEFINED",
|
||||
"UserDefinedPurpose": "REPOSITORY",
|
||||
"Description": "The source code repository of the software collection.",
|
||||
"WWWHomePageURL": "https://github.com/IfcOpenShell/IfcOpenShell.git",
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user