mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Still cleaning up related to ownership histories. See #1399.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import bpy
|
||||
import json
|
||||
import addon_utils
|
||||
import blenderbim.bim.decoration as decoration
|
||||
import ifcopenshell.api.owner.settings
|
||||
from bpy.app.handlers import persistent
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.attribute.data import Data as AttributeData
|
||||
@@ -46,14 +48,13 @@ def subscribe_to(object, data_path, callback):
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def purge_module_data():
|
||||
from blenderbim.bim import modules
|
||||
|
||||
for module in modules.values():
|
||||
if not module:
|
||||
continue
|
||||
for name in modules.keys():
|
||||
try:
|
||||
getattr(getattr(module, "data"), "Data").purge()
|
||||
getattr(getattr(getattr(ifcopenshell.api, name), "data"), "Data").purge()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
@@ -101,6 +102,28 @@ def storeIdMap(scene):
|
||||
|
||||
@persistent
|
||||
def setDefaultProperties(scene):
|
||||
ifcopenshell.api.owner.settings.get_person = (
|
||||
lambda: IfcStore.get_file().by_id(int(bpy.context.scene.BIMOwnerProperties.user_person))
|
||||
if bpy.context.scene.BIMOwnerProperties.user_person
|
||||
else None
|
||||
)
|
||||
ifcopenshell.api.owner.settings.get_organisation = (
|
||||
lambda: IfcStore.get_file().by_id(int(bpy.context.scene.BIMOwnerProperties.user_organisation))
|
||||
if bpy.context.scene.BIMOwnerProperties.user_organisation
|
||||
else None
|
||||
)
|
||||
ifcopenshell.api.owner.settings.settings["ApplicationIdentifier"] = "BlenderBIM"
|
||||
ifcopenshell.api.owner.settings.settings["ApplicationFullName"] = "BlenderBIM Add-on"
|
||||
ifcopenshell.api.owner.settings.settings["Version"] = ".".join(
|
||||
[
|
||||
str(x)
|
||||
for x in [
|
||||
addon.bl_info.get("version", (-1, -1, -1))
|
||||
for addon in addon_utils.modules()
|
||||
if addon.bl_info["name"] == "BlenderBIM"
|
||||
][0]
|
||||
]
|
||||
)
|
||||
if len(bpy.context.scene.DocProperties.drawing_styles) == 0:
|
||||
drawing_style = bpy.context.scene.DocProperties.drawing_styles.add()
|
||||
drawing_style.name = "Technical"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.owner.data import Data
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
|
||||
@@ -9,6 +9,7 @@ from . import ifc
|
||||
from . import annotation
|
||||
from . import decoration
|
||||
import bpy
|
||||
from blenderbim.bim.handler import purge_module_data
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from bpy.types import PropertyGroup
|
||||
from bpy.props import (
|
||||
@@ -38,16 +39,7 @@ def updateIfcFile(self, context):
|
||||
if context.scene.BIMProperties.ifc_file:
|
||||
IfcStore.file = None
|
||||
IfcStore.schema = None
|
||||
# Purge data cache
|
||||
from blenderbim.bim import modules
|
||||
|
||||
for module in modules.values():
|
||||
if not module:
|
||||
continue
|
||||
try:
|
||||
getattr(getattr(module, "data"), "Data").purge()
|
||||
except AttributeError:
|
||||
pass
|
||||
purge_module_data()
|
||||
|
||||
|
||||
def getDiagramScales(self, context):
|
||||
|
||||
@@ -11,6 +11,8 @@ class Usecase:
|
||||
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()
|
||||
if self.file.schema != "IFC2X3":
|
||||
if not self.settings["person"] or not self.settings["organisation"]:
|
||||
return
|
||||
@@ -22,7 +24,7 @@ class Usecase:
|
||||
"OwningUser": user,
|
||||
"OwningApplication": application,
|
||||
"State": "READWRITE",
|
||||
"ChangeAction": self.settings["ChangeAction"] or "ADDED",
|
||||
"ChangeAction": "ADDED",
|
||||
"LastModifiedDate": int(time.time()),
|
||||
"LastModifyingUser": user,
|
||||
"LastModifyingApplication": application,
|
||||
|
||||
@@ -1,33 +1,13 @@
|
||||
# import bpy
|
||||
# import addon_utils
|
||||
def get_person():
|
||||
pass
|
||||
|
||||
|
||||
def get_organisation():
|
||||
pass
|
||||
|
||||
|
||||
settings = {
|
||||
"person": None,
|
||||
"organisation": None,
|
||||
"ApplicationIdentifier": "",
|
||||
"ApplicationFullName": "",
|
||||
"Version": "",
|
||||
"ChangeAction": "NOTDEFINED",
|
||||
}
|
||||
|
||||
|
||||
# settings = {
|
||||
# "person": file.by_id(int(bpy.context.scene.BIMOwnerProperties.user_person)),
|
||||
# "organisation": file.by_id(int(bpy.context.scene.BIMOwnerProperties.user_organisation)),
|
||||
# "ApplicationIdentifier": "BlenderBIM",
|
||||
# "ApplicationFullName": "BlenderBIM Add-on",
|
||||
# "Version": get_application_version(),
|
||||
# }
|
||||
#
|
||||
#
|
||||
# def get_application_version():
|
||||
# return ".".join(
|
||||
# [
|
||||
# str(x)
|
||||
# for x in [
|
||||
# addon.bl_info.get("version", (-1, -1, -1))
|
||||
# for addon in addon_utils.modules()
|
||||
# if addon.bl_info["name"] == "BlenderBIM"
|
||||
# ][0]
|
||||
# ]
|
||||
# )
|
||||
|
||||
@@ -11,9 +11,11 @@ class Usecase:
|
||||
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()
|
||||
if not self.settings["element"].OwnerHistory:
|
||||
self.settings["element"].OwnerHistory = create_owner_history.Usecase(self.file, self.settings).execute()
|
||||
return
|
||||
return self.settings["element"].OwnerHistory
|
||||
if len(self.file.get_inverse(self.settings["element"].OwnerHistory)) > 1:
|
||||
old_history = self.settings["element"].OwnerHistory
|
||||
self.settings["element"].OwnerHistory = self.file.create_entity("IfcOwnerHistory")
|
||||
@@ -21,11 +23,11 @@ class Usecase:
|
||||
self.settings["element"].OwnerHistory[i] = attribute
|
||||
user = self.get_user()
|
||||
application = self.get_application()
|
||||
self.settings["element"].OwnerHistory.ChangeAction = self.settings["ChangeAction"]
|
||||
self.settings["element"].OwnerHistory.ChangeAction = "MODIFIED"
|
||||
self.settings["element"].OwnerHistory.LastModifiedDate = int(time.time())
|
||||
self.settings["element"].OwnerHistory.LastModifyingUser = user
|
||||
self.settings["element"].OwnerHistory.LastModifyingApplication = application
|
||||
return self.settings["OwnerHistory"]
|
||||
return self.settings["element"].OwnerHistory
|
||||
|
||||
def get_user(self):
|
||||
for element in self.file.by_type("IfcPersonAndOrganization"):
|
||||
|
||||
Reference in New Issue
Block a user