Spatial container drop down to show only spatial objects

Example - https://i.imgur.com/v8p4D57.png (it's ignoring walls).
Since we now filter valid elements in poll_container_obj, then there is no need to check it twice in update_container_obj.
This commit is contained in:
Andrej730
2024-10-30 18:45:45 +05:00
parent e463407de7
commit 037b5d1bc1
+10 -23
View File
@@ -80,24 +80,6 @@ def update_element_mode(self: "BIMSpatialDecompositionProperties", context: bpy.
tool.Spatial.load_contained_elements()
def update_container_obj(self: "BIMObjectSpatialProperties", context: bpy.types.Context) -> None:
if self.container_obj is None or not (obj := context.active_object):
return
if not (element := tool.Ifc.get_entity(self.container_obj)):
self.container_obj = None
return
if tool.Spatial.can_contain(element, obj):
return
if (
(container := ifcopenshell.util.element.get_container(element))
and (container_obj := tool.Ifc.get_object(container))
and tool.Spatial.can_contain(container, obj)
):
self.container_obj = container_obj
return
self.container_obj = None
def update_grid_is_locked(self, context):
if not tool.Ifc.get():
return
@@ -140,15 +122,20 @@ def update_grid_is_visible(self: "BIMGridProperties", context: bpy.types.Context
bpy.ops.bim.toggle_grids(is_visible=self.is_visible)
def poll_container_obj(self, obj):
return obj is None or tool.Ifc.get_entity(obj)
def poll_container_obj(self: "BIMObjectSpatialProperties", container_obj: bpy.types.Object) -> bool:
obj = self.id_data
if (
(container := tool.Ifc.get_entity(container_obj))
and (tool.Ifc.get_entity(obj))
and tool.Spatial.can_contain(container, obj)
):
return True
return False
class BIMObjectSpatialProperties(PropertyGroup):
is_editing: BoolProperty(name="Is Editing")
container_obj: PointerProperty(
type=bpy.types.Object, name="Container", update=update_container_obj, poll=poll_container_obj
)
container_obj: PointerProperty(type=bpy.types.Object, name="Container", poll=poll_container_obj)
class BIMContainer(PropertyGroup):