Fix failing selecting products tests (3aa5ddb07)

After 3aa5ddb07 `select_products` adds to current selection, instead of resetting it.

So couple tests started to fail since they create new objects and `view_layer` is not yet updated (previously `bpy.ops.object.select_all(action="DESELECT")` was also implicitly updating view layer).
```
FAILED test/tool/test_spatial.py::TestSelectProducts::test_select_products - AssertionError: assert bpy.data.objects['Object'] in []
FAILED test/tool/test_system.py::TestSelectSystemProducts::test_run - AssertionError: assert bpy.data.objects['Object'] in []
```
This commit is contained in:
Andrej730
2025-11-04 17:06:08 +05:00
parent d2126e5929
commit 4e1d0bcf22
+4 -1
View File
@@ -175,9 +175,12 @@ class Spatial(bonsai.core.tool.Spatial):
@classmethod
def select_products(cls, products: Iterable[ifcopenshell.entity_instance], unhide: bool = False) -> None:
assert (view_layer := bpy.context.view_layer)
# Update view layer, otherwise `objects` might be missing just created objects.
view_layer.update()
for product in products:
obj = tool.Ifc.get_object(product)
if obj and bpy.context.view_layer.objects.get(obj.name):
if obj and view_layer.objects.get(obj.name):
if unhide:
obj.hide_set(False)
obj.select_set(True)