Regression: Deleting Objects in a View Layer leaves None in the View Layer's .objects for the script duration #113378

Open
opened 2023-10-07 02:05:20 +02:00 by Thomas Barlow · 4 comments
Member

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 536.40

Blender Version
Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: a95bf1ac01be, also version: 3.6.4, version 4.0.0b 2023-09-28 00:03, hash: 751c9ef620a0 and version 4.1.0a 2023-10-05, hash: c68f568eb305
Worked: version: 3.3.11

Short description of error
Deleting one or more Objects that are in a ViewLayer leaves a single None entry in that ViewLayer's .objects for the remaining duration of the script.

This only seems to affect ViewLayer.objects.
Scene.objects and Collection.objects work as expected.

This broke part of a community addon that assumed ViewLayer.objects would only ever contain Object instances.

3.3.11 and older 3.4.0 and newer
image image

Exact steps for others to reproduce the error

import bpy

context = bpy.context

for o in context.view_layer.objects:
    print(list(context.view_layer.objects))
    bpy.data.objects.remove(o)
print("view layer objects after deletion:")
print(len(context.view_layer.objects))
print(list(context.view_layer.objects))
  1. Ensure there is at least one Object in the current view layer
  2. Open the System Console to be able to observe the script output
  3. Run the above script
  4. Observe that, in 3.4.0+, after removing an Object, context.view_layer.objects contains a None element
  5. Run the above script again
  6. Observe that context.view_layer.objects is now empty as expected
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 536.40 **Blender Version** Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: `a95bf1ac01be`, also version: 3.6.4, version 4.0.0b 2023-09-28 00:03, hash: `751c9ef620a0` and version 4.1.0a 2023-10-05, hash: `c68f568eb305` Worked: version: 3.3.11 **Short description of error** Deleting one or more Objects that are in a ViewLayer leaves a single `None` entry in that ViewLayer's .objects for the remaining duration of the script. This only seems to affect `ViewLayer.objects`. `Scene.objects` and `Collection.objects` work as expected. This broke part of a community addon that assumed `ViewLayer.objects` would only ever contain `Object` instances. | 3.3.11 and older | 3.4.0 and newer | | -- | -- | | ![image](/attachments/ad90d3e2-3e42-44d9-b2fa-288099e1c2c9) | ![image](/attachments/eb994f00-e376-4b3f-90fd-3cf7a1067c05) | **Exact steps for others to reproduce the error** ```py import bpy context = bpy.context for o in context.view_layer.objects: print(list(context.view_layer.objects)) bpy.data.objects.remove(o) print("view layer objects after deletion:") print(len(context.view_layer.objects)) print(list(context.view_layer.objects)) ``` 1. Ensure there is at least one Object in the current view layer 2. Open the System Console to be able to observe the script output 3. Run the above script 4. Observe that, in 3.4.0+, after removing an Object, `context.view_layer.objects` contains a `None` element 5. Run the above script again 6. Observe that `context.view_layer.objects` is now empty as expected
7.0 KiB
7.5 KiB
Thomas Barlow added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-10-07 02:05:21 +02:00
Author
Member

Perhaps of note is if I instead use the experimental bpy.data.batch_remove() to delete the Objects in the View Layer it replaces each Object with None in 3.4.0 and newer rather than leaving a single None element:

import bpy

context = bpy.context

bpy.data.batch_remove(context.view_layer.objects)
print("view layer objects after deletion:")
print(len(context.view_layer.objects))
print(list(context.view_layer.objects))

image

In 3.3.11, view_layer.objects will immediately be empty, as expected, when using bpy.data.batch_remove() to delete all the Objects, just like when using bpy.data.objects.remove().

Perhaps of note is if I instead use the experimental `bpy.data.batch_remove()` to delete the Objects in the View Layer it replaces each Object with `None` in 3.4.0 and newer rather than leaving a single `None` element: ```py import bpy context = bpy.context bpy.data.batch_remove(context.view_layer.objects) print("view layer objects after deletion:") print(len(context.view_layer.objects)) print(list(context.view_layer.objects)) ``` ![image](/attachments/21a15383-88ba-4d7a-8fae-91ebc5a09037) In 3.3.11, `view_layer.objects` will immediately be empty, as expected, when using `bpy.data.batch_remove()` to delete all the Objects, just like when using `bpy.data.objects.remove()`.
2.5 KiB
Member

Note that a simple bpy.context.view_layer.update() can solve the issue, still, will check when behavior changed

Note that a simple `bpy.context.view_layer.update()` can solve the issue, still, will check when behavior changed
Member

I can confirm

I can confirm
Pratik Borhade added
Module
User Interface
Status
Confirmed
Interest
Python API
and removed
Status
Needs Triage
labels 2023-10-11 07:44:11 +02:00
Member

will check when behavior changed

Maybe 68589a31eb ?

> will check when behavior changed Maybe 68589a31ebfb79165f99a979357d237e5413e904 ?
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113378
No description provided.