mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Fix breaking spatial containers UI when spatial container is deleted
E.g. if you had some container selected in `active_container_id` and then it got deleted UI would break and won't allow to reload the spatial manger until you reload .ifc completely
This commit is contained in:
@@ -32,7 +32,7 @@ class SpatialData:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"parent_container_id": cls.get_parent_container_id(),
|
"parent_container_id": cls.parent_container_id(),
|
||||||
"is_directly_contained": cls.is_directly_contained(),
|
"is_directly_contained": cls.is_directly_contained(),
|
||||||
"label": cls.label(),
|
"label": cls.label(),
|
||||||
"references": cls.references(),
|
"references": cls.references(),
|
||||||
@@ -55,12 +55,12 @@ class SpatialData:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_parent_container_id(cls):
|
def parent_container_id(cls):
|
||||||
container_id = bpy.context.scene.BIMSpatialProperties.active_container_id
|
container_id = bpy.context.scene.BIMSpatialProperties.active_container_id
|
||||||
if not container_id:
|
if not container_id:
|
||||||
return
|
return
|
||||||
container = tool.Ifc.get().by_id(container_id)
|
container = tool.Ifc.get_entity_by_id(container_id)
|
||||||
if container.is_a("IfcProject"):
|
if not container or container.is_a("IfcProject"):
|
||||||
return
|
return
|
||||||
return container.Decomposes[0].RelatingObject.id()
|
return container.Decomposes[0].RelatingObject.id()
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ class BIM_PT_SpatialManager(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.alignment = "RIGHT"
|
row.alignment = "RIGHT"
|
||||||
row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="Select Children")
|
row.operator("bim.select_decomposed_elements", icon="RESTRICT_SELECT_OFF", text="Select Children")
|
||||||
if SpatialData.data["containers"][ifc_definition_id]["type"] in ["IfcBuildingStorey", "IfcBuilding"]:
|
spatial_data = SpatialData.data["containers"].get(ifc_definition_id, None)
|
||||||
|
if spatial_data and spatial_data["type"] in ["IfcBuildingStorey", "IfcBuilding"]:
|
||||||
row.operator("bim.add_building_storey", icon="ADD", text="Add storey").part_class = "IfcBuildingStorey"
|
row.operator("bim.add_building_storey", icon="ADD", text="Add storey").part_class = "IfcBuildingStorey"
|
||||||
row.operator("bim.delete_container", icon="X", text="Delete").container = ifc_definition_id
|
row.operator("bim.delete_container", icon="X", text="Delete").container = ifc_definition_id
|
||||||
self.layout.template_list(
|
self.layout.template_list(
|
||||||
|
|||||||
Reference in New Issue
Block a user