Fix #6066. Bug where spatial manager didn't toggle visibility correctly for spaces.

Previously I was only toggling Blender collections which is an
optimisation for large projects but will result in incorrect behaviour
if things aren't in the collection you think they're in. So for now it's
slower but more correct. We can optimise it later.
This commit is contained in:
Dion Moult
2025-01-30 19:17:12 +11:00
parent 2ad48aba36
commit 2570864f58
@@ -419,28 +419,21 @@ class SetContainerVisibility(bpy.types.Operator):
def execute(self, context): def execute(self, context):
if self.mode == "ISOLATE": if self.mode == "ISOLATE":
if tool.Ifc.get_schema() == "IFC2X3": context_override = tool.Blender.get_viewport_context()
containers = tool.Ifc.get().by_type("IfcSpatialStructureElement") with context.temp_override(**context_override):
else: bpy.ops.object.hide_view_set(unselected=True)
containers = set(tool.Ifc.get().by_type("IfcSpatialElement")) bpy.ops.object.hide_view_set(unselected=False)
containers -= set(tool.Ifc.get().by_type("IfcSpatialZone"))
for container in containers:
if obj := tool.Ifc.get_object(container):
if collection := obj.BIMObjectProperties.collection:
collection.hide_viewport = True
should_hide = False should_hide = False
else: else:
should_hide = self.mode == "HIDE" should_hide = self.mode == "HIDE"
container = tool.Ifc.get().by_id(self.container) container = tool.Ifc.get().by_id(self.container)
queue = [container] elements = ifcopenshell.util.element.get_decomposition(container, is_recursive=self.should_include_children)
while queue: for element in elements:
container = queue.pop() if obj := tool.Ifc.get_object(element):
if obj := tool.Ifc.get_object(container): obj.hide_set(should_hide)
if collection := obj.BIMObjectProperties.collection: for collection in obj.users_collection:
collection.hide_viewport = should_hide collection.hide_viewport = False
if self.should_include_children:
queue.extend(ifcopenshell.util.element.get_parts(container))
return {"FINISHED"} return {"FINISHED"}