depsgraph.view_layer.name driver expression doesn't work correctly #106586

Open
opened 2023-04-05 12:01:42 +02:00 by Christoph Werner · 9 comments

System Information
Operating system: Windows 11
Graphics card: Geforce RTX 3090

Blender Version
Broken: 3.3.5 LTS
Broken: 3.5

Short description of error
I use a driver expression to control modifiers visibility or shader values depending on a view layer name. If the needed view layer is active, then values change. All works well when switching viewlayers manually inside the viewport of my scene. But as soon as I render the scene, the expression is ignored and nothing happen.

Exact steps for others to reproduce the error

  • Open attached file
  • Change view layer few times

Driver will change only once. This also doesn't work when rendering.

image

**System Information** Operating system: Windows 11 Graphics card: Geforce RTX 3090 **Blender Version** Broken: 3.3.5 LTS Broken: 3.5 **Short description of error** I use a driver expression to control modifiers visibility or shader values depending on a view layer name. If the needed view layer is active, then values change. All works well when switching viewlayers manually inside the viewport of my scene. But as soon as I render the scene, the expression is ignored and nothing happen. **Exact steps for others to reproduce the error** * Open attached file * Change view layer few times Driver will change only once. This also doesn't work when rendering. ![image](/attachments/2ad109de-b39d-47df-968b-255816c826e4)
Christoph Werner added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-04-05 12:01:43 +02:00
Read prefs: "C:\Users\rfnei\AppData\Roaming\Blender Foundation\Blender\3.6\config\userpref.blend"
Read blend: "C:\Users\rfnei\Downloads\invertedhull_outlines.blend"
        BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support

Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0
For target: (type=Object, name="Suzanne", property=show_render, property_index=-1)

        BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support

Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0
For target: (type=Object, name="Suzanne.001", property=show_viewport, property_index=-1)

        BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support

Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0
For target: (type=Object, name="Suzanne", property=show_viewport, property_index=-1)

        BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support

Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0
For target: (type=Object, name="Suzanne.001", property=show_render, property_index=-1)

WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_viewport[0]
        BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support
WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_render[0]

Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1
For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1)

Read blend: "C:\Users\rfnei\Downloads\invertedhull_outlines.blend"
WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_viewport[0]
WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_render[0]

Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1
For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1)

Traceback (most recent call last):
  File "<bpy driver>", line 1, in <module>
NameError: name 'view_layer' is not defined
``` Read prefs: "C:\Users\rfnei\AppData\Roaming\Blender Foundation\Blender\3.6\config\userpref.blend" Read blend: "C:\Users\rfnei\Downloads\invertedhull_outlines.blend" BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0 For target: (type=Object, name="Suzanne", property=show_render, property_index=-1) BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0 For target: (type=Object, name="Suzanne.001", property=show_viewport, property_index=-1) BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0 For target: (type=Object, name="Suzanne", property=show_viewport, property_index=-1) BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support Error in PyDriver: expression failed: 1 if depsgraph.view_layer.name == 'lines_invertedhull' else 0 For target: (type=Object, name="Suzanne.001", property=show_render, property_index=-1) WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_viewport[0] BPY_driver_exec: restricted access disallows name 'view_layer', enable auto-execution to support WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_render[0] Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1 For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1) Read blend: "C:\Users\rfnei\Downloads\invertedhull_outlines.blend" WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_viewport[0] WARN (bke.anim_sys): C:\Users\blender\git\blender-vdev\blender.git\source\blender\blenkernel\intern\anim_sys.c:4192 BKE_animsys_eval_driver: invalid driver - modifiers["Solidify"].show_render[0] Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1 For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1) Traceback (most recent call last): File "<bpy driver>", line 1, in <module> NameError: name 'view_layer' is not defined ```

I applied such driver to scale and it doesn't work here. I wasn't aware, that depsgraph variable could be accessed in such way. Can you provide working .blend file?

I applied such driver to scale and it doesn't work here. I wasn't aware, that `depsgraph` variable could be accessed in such way. Can you provide working .blend file?
Richard Antalik added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-04-13 06:28:15 +02:00

I applied such driver to scale and it doesn't work here. I wasn't aware, that depsgraph variable could be accessed in such way. Can you provide working .blend file?

An example file is provided in my first post.

> I applied such driver to scale and it doesn't work here. I wasn't aware, that `depsgraph` variable could be accessed in such way. Can you provide working .blend file? An example file is provided in my first post.

Ah sorry, I have missed it. But Even with provided file driver value does not change here.

Also it says as mentioned above:

Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1
For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1)

Traceback (most recent call last):
  File "<bpy driver>", line 1, in <module>
NameError: name 'view_layer' is not defined

Are you sure that this drivers actually works in viewport?

Ah sorry, I have missed it. But Even with provided file driver value does not change here. Also it says as mentioned above: ``` Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1 For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1) Traceback (most recent call last): File "<bpy driver>", line 1, in <module> NameError: name 'view_layer' is not defined ``` Are you sure that this drivers actually works in viewport?

... I have noticed, that in provided file it was missing depsgraph in expression. With that it works in a way, that it changes value to 0, but never to 1, which is inconsistent behavior at least. So I guess I can confirm this issue.

... I have noticed, that in provided file it was missing `depsgraph` in expression. With that it works in a way, that it changes value to 0, but never to 1, which is inconsistent behavior at least. So I guess I can confirm this issue.

Are you sure that this drivers actually works in viewport?

Yes they do. If you change the viewports in my example scene, the modifiers change also. Switch to "lines_invertedhull" viewlayer and you'll see the modifiers for the outlines are active.

image

> Are you sure that this drivers actually works in viewport? Yes they do. If you change the viewports in my example scene, the modifiers change also. Switch to "lines_invertedhull" viewlayer and you'll see the modifiers for the outlines are active. ![image](/attachments/0918be53-9ccf-4428-aadd-d138f7c816a3)
726 KiB

Ah sorry, I have missed it. But Even with provided file driver value does not change here.

Also it says as mentioned above:

Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1
For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1)

Traceback (most recent call last):
  File "<bpy driver>", line 1, in <module>
NameError: name 'view_layer' is not defined

Are you sure that this drivers actually works in viewport?

> Ah sorry, I have missed it. But Even with provided file driver value does not change here. > > Also it says as mentioned above: > ``` > Error in PyDriver: expression failed: 0 if view_layer.name == 'lines_invertedhull' else 1 > For target: (type=NodeTree, name="Shader Nodetree", property=default_value, property_index=-1) > > Traceback (most recent call last): > File "<bpy driver>", line 1, in <module> > NameError: name 'view_layer' is not defined > ``` > > Are you sure that this drivers actually works in viewport?
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2023-04-14 11:13:03 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-04-14 11:13:16 +02:00

Small info to the Blender Developers: I clicked on "Close issue" button for accident, because both buttons are placed close side by side. The issue was immediately closed. This is not a good behavior.

Please add a security question window before closing an issue. I know this takes some more time, but avoids unintentionally issue closing!

Small info to the **Blender Developers**: I clicked on "Close issue" button for accident, because both buttons are placed close side by side. The issue was immediately closed. This is not a good behavior. Please add a security question window before closing an issue. I know this takes some more time, but avoids unintentionally issue closing!
Richard Antalik changed title from depsgraph.view_layer.name driver expression doesn't work in renders to depsgraph.view_layer.name driver expression doesn't work correctly 2023-04-14 12:00:07 +02:00
Richard Antalik added
Module
Nodes & Physics
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-04-14 12:00:57 +02:00

We do check updates on all reports, so chances of closing something accidentally are very slim. But I agree that the button is annoyingly close to comment button.

We do check updates on all reports, so chances of closing something accidentally are very slim. But I agree that the button is annoyingly close to comment button.
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#106586
No description provided.