mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Spatial containment now distinguishes between direct and indirect containment
This commit is contained in:
@@ -114,6 +114,7 @@ def active_object_callback():
|
||||
stored_obj = IfcStore.get_element(obj.BIMObjectProperties.ifc_definition_id)
|
||||
if stored_obj and stored_obj != obj:
|
||||
bpy.ops.bim.copy_class(obj=obj.name)
|
||||
refresh_ui_data()
|
||||
|
||||
|
||||
def subscribe_to(object, data_path, callback):
|
||||
@@ -135,9 +136,20 @@ def subscribe_to(object, data_path, callback):
|
||||
)
|
||||
|
||||
|
||||
def refresh_ui_data():
|
||||
from blenderbim.bim import modules
|
||||
|
||||
for name, value in modules.items():
|
||||
try:
|
||||
getattr(value, "data").refresh()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
def purge_module_data():
|
||||
from blenderbim.bim import modules
|
||||
|
||||
refresh_ui_data()
|
||||
for name, value in modules.items():
|
||||
try:
|
||||
getattr(getattr(getattr(ifcopenshell.api, name), "data"), "Data").purge()
|
||||
|
||||
@@ -20,6 +20,10 @@ import bpy
|
||||
import blenderbim.tool as tool
|
||||
|
||||
|
||||
def refresh():
|
||||
ContextData.is_loaded = False
|
||||
|
||||
|
||||
class ContextData:
|
||||
data = {}
|
||||
is_loaded = False
|
||||
|
||||
@@ -20,6 +20,7 @@ import bpy
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.core.context as core
|
||||
import blenderbim.bim.module.context.data
|
||||
import blenderbim.bim.handler
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.context.data import Data
|
||||
|
||||
@@ -27,7 +28,7 @@ from ifcopenshell.api.context.data import Data
|
||||
class Operator:
|
||||
def execute(self, context):
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
blenderbim.bim.module.context.data.ContextData.is_loaded = False
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ import bpy
|
||||
import blenderbim.tool as tool
|
||||
|
||||
|
||||
def refresh():
|
||||
PeopleData.is_loaded = False
|
||||
OrganisationsData.is_loaded = False
|
||||
OwnerData.is_loaded = False
|
||||
|
||||
|
||||
class RolesAddressesData:
|
||||
@classmethod
|
||||
def get_roles(cls, parent):
|
||||
|
||||
@@ -21,15 +21,14 @@ import ifcopenshell.api
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.core.owner as core
|
||||
import blenderbim.bim.module.owner.data
|
||||
import blenderbim.bim.handler
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class Operator:
|
||||
def execute(self, context):
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
blenderbim.bim.module.owner.data.PeopleData.is_loaded = False
|
||||
blenderbim.bim.module.owner.data.OrganisationsData.is_loaded = False
|
||||
blenderbim.bim.module.owner.data.OwnerData.is_loaded = False
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ import blenderbim.tool as tool
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def refresh():
|
||||
SpatialData.is_loaded = False
|
||||
|
||||
|
||||
class SpatialData:
|
||||
data = {}
|
||||
is_loaded = False
|
||||
@@ -33,6 +37,7 @@ class SpatialData:
|
||||
"container_id": cls.get_container_id(),
|
||||
"container_list_settings": cls.get_container_list_settings(),
|
||||
"is_contained": cls.is_contained(),
|
||||
"is_directly_contained": cls.is_directly_contained(),
|
||||
"label": cls.get_label(),
|
||||
}
|
||||
cls.is_loaded = True
|
||||
@@ -68,4 +73,11 @@ class SpatialData:
|
||||
def get_label(cls):
|
||||
container = ifcopenshell.util.element.get_container(tool.Ifc.get_entity(bpy.context.active_object))
|
||||
if container:
|
||||
return f"{container.is_a()}/{container.Name or ''}"
|
||||
label = f"{container.is_a()}/{container.Name or ''}"
|
||||
if not cls.is_directly_contained():
|
||||
label += "*"
|
||||
return label
|
||||
|
||||
@classmethod
|
||||
def is_directly_contained(cls):
|
||||
return bool(getattr(tool.Ifc.get_entity(bpy.context.active_object), "ContainedInStructure"))
|
||||
|
||||
@@ -21,6 +21,7 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.core.spatial as core
|
||||
import blenderbim.bim.handler
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.spatial.data import SpatialData
|
||||
|
||||
@@ -28,7 +29,7 @@ from blenderbim.bim.module.spatial.data import SpatialData
|
||||
class Operator:
|
||||
def execute(self, context):
|
||||
IfcStore.execute_ifc_operator(self, context)
|
||||
SpatialData.is_loaded = False
|
||||
blenderbim.bim.handler.refresh_ui_data()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ class BIM_PT_spatial(Panel):
|
||||
if SpatialData.data["is_contained"]:
|
||||
row.label(text=SpatialData.data["label"])
|
||||
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
||||
row.operator("bim.remove_container", icon="X", text="")
|
||||
if SpatialData.data["is_directly_contained"]:
|
||||
row.operator("bim.remove_container", icon="X", text="")
|
||||
else:
|
||||
row.label(text="This object is not spatially contained")
|
||||
row.operator("bim.enable_editing_container", icon="GREASEPENCIL", text="")
|
||||
|
||||
Reference in New Issue
Block a user