Clear IfcStore when you load a new file. See #1222.

This commit is contained in:
Dion Moult
2021-01-26 21:28:54 +11:00
parent bbde897113
commit b71febab0d
4 changed files with 15 additions and 1 deletions
@@ -163,6 +163,7 @@ if bpy is not None:
bpy.utils.register_class(cls)
bpy.app.handlers.depsgraph_update_post.append(on_register)
bpy.app.handlers.load_post.append(prop.setDefaultProperties)
bpy.app.handlers.load_post.append(prop.clearIfcStore)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties)
@@ -1,5 +1,6 @@
from bpy.types import Panel
from blenderbim.bim.module.aggregate.data import Data
from blenderbim.bim.ifc import IfcStore
class BIM_PT_aggregate(Panel):
@@ -15,6 +16,8 @@ class BIM_PT_aggregate(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
return False
if props.ifc_definition_id not in Data.products:
Data.load(props.ifc_definition_id)
if not Data.products[props.ifc_definition_id]:
@@ -27,7 +27,12 @@ class BIM_PT_object_material(Panel):
@classmethod
def poll(cls, context):
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not hasattr(IfcStore.get_file().by_id(props.ifc_definition_id), "HasAssociations"):
return False
return True
def draw(self, context):
self.file = IfcStore.get_file()
@@ -35,6 +35,11 @@ sheets_enum = []
vector_styles_enum = []
@persistent
def clearIfcStore(scene):
IfcStore.file = None
@persistent
def setDefaultProperties(scene):
if len(bpy.context.scene.DocProperties.drawing_styles) == 0: