Unable to set active material output node using Python #96292

Closed
opened 2022-03-10 12:32:05 +01:00 by Greg Zaal · 14 comments
Member

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 497.29

Blender Version
Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: c77597cd0e
Worked: 3.0

This changed in 7e712b2d6a

Short description of error
It seems to be (inconsistently) no longer possible to set the world/shader node tree's active output using python.

Running node.is_active_output = True in a fresh scene does anything. But if you (in the UI) click on one of the output nodes, setting it as the active output, then from that point onwards doing node.is_active_output = True will indeed work.

Exact steps for others to reproduce the error

  1. Starting from factory defaults
  2. In a python console editor, run: node = C.scene.world.node_tree.nodes.new('ShaderNodeOutputWorld') to create a new world output node. This node is named World Output.001. The original output node is named World Output.
  3. Check the current state of the active output node:
  4. C.scene.world.node_tree.nodes['World Output'].is_active_output - the result is True as this is the original node.
  5. C.scene.world.node_tree.nodes['World Output.001'].is_active_output - the result is False as this is the new node.
  6. Try set the new node as active output using C.scene.world.node_tree.nodes['World Output.001'].is_active_output = True. Nothing happens, the value remains False even after we set it.
  7. In the UI, click on the newly created node, setting it as the active output (verify this with the code above if needed, is_active_output is now True for the new node)
  8. Click on the original node to set that as the active output.
  9. Run C.scene.world.node_tree.nodes['World Output.001'].is_active_output = True again, this time it successfully changes the tree's active output to that node.

As a side note, is there some other workaround way I can consistently set the node tree's active output? I need to fix an add-on and can't wait for this to be patched.

**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 497.29 **Blender Version** Broken: version: 3.1.0, branch: master, commit date: 2022-03-08 18:16, hash: `c77597cd0e` Worked: 3.0 This changed in 7e712b2d6a **Short description of error** It seems to be (inconsistently) no longer possible to set the world/shader node tree's active output using python. Running `node.is_active_output = True` in a fresh scene does anything. But if you (in the UI) click on one of the output nodes, setting it as the active output, then from that point onwards doing `node.is_active_output = True` will indeed work. **Exact steps for others to reproduce the error** 1. Starting from factory defaults 2. In a python console editor, run: `node = C.scene.world.node_tree.nodes.new('ShaderNodeOutputWorld')` to create a new world output node. This node is named `World Output.001`. The original output node is named `World Output`. 3. Check the current state of the active output node: 4. `C.scene.world.node_tree.nodes['World Output'].is_active_output` - the result is `True` as this is the original node. 5. `C.scene.world.node_tree.nodes['World Output.001'].is_active_output` - the result is `False` as this is the new node. 6. Try set the new node as active output using `C.scene.world.node_tree.nodes['World Output.001'].is_active_output = True`. Nothing happens, the value remains `False` even after we set it. 7. In the UI, click on the newly created node, setting it as the active output (verify this with the code above if needed, `is_active_output` is now `True` for the new node) 8. Click on the original node to set that as the active output. 8. Run `C.scene.world.node_tree.nodes['World Output.001'].is_active_output = True` again, this time it successfully changes the tree's active output to that node. As a side note, is there some other workaround way I can consistently set the node tree's active output? I need to fix an add-on and can't wait for this to be patched.
Author
Member

Added subscriber: @GregZaal

Added subscriber: @GregZaal
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Can confirm (to some extend).
In 3.0, it was possible to have 2 active outputs at the same time, setting World Output.001 active did not set World Output inactive (this was wrong, too).
There has probably been some fix that does not allow for that anymore (otoh, it did not take into account that this prevents setting it active from python in some situations), will check

Can confirm (to some extend). In 3.0, it was possible to have 2 active outputs at the same time, setting `World Output.001` active did not set `World Output` inactive (this was wrong, too). There has probably been some fix that does not allow for that anymore (otoh, it did not take into account that this prevents setting it active from python in some situations), will check
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Author
Member

I guess ideally we have some node_tree.set_active_output_node function in the API, and not have to rely on the python code having to make sure to set all outputs to False except one.

I saw there was also a node_tree.active_output property, but this was always -1 and didn't seem writable.

I guess ideally we have some `node_tree.set_active_output_node` function in the API, and not have to rely on the python code having to make sure to set all outputs to `False` except one. I saw there was also a `node_tree.active_output` property, but this was always `-1` and didn't seem writable.
Member

This changed in 7e712b2d6a btw.

This changed in 7e712b2d6a btw.
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Even though this was not quite right in 3.0 either, will still set this to High prio (since now it seems this is not possible to set at all).

@JacquesLucke: opinions?

Even though this was not quite right in 3.0 either, will still set this to High prio (since now it seems this is not possible to set at all). @JacquesLucke: opinions?
Jacques Lucke self-assigned this 2022-03-10 17:42:12 +01:00
Member

I saw there was also a node_tree.active_output property, but this was always -1 and didn't seem writable.

Think that's the index of the active output socket in a node group.


The fix seems to be to make the other outputs of the same type inactive.

> I saw there was also a node_tree.active_output property, but this was always -1 and didn't seem writable. Think that's the index of the active output socket in a node group. --- The fix seems to be to make the other outputs of the same type inactive.
Member

FYI, bug reports that require the python console are sometimes a bit annoying, because I have to type/copy so much every time I want to reproduce it. Usually I end up preparing myself a file that just has a small script in it that I can just run to reproduce the bug. It doesn't matter too much, but if you happen to report similar bugs in the future, maybe consider writing a small(!) script instead of using the console.

E.g. this is the script I used for this bug:

import bpy

n1 = bpy.context.scene.world.node_tree.nodes['World Output']
n2 = bpy.context.scene.world.node_tree.nodes['World Output.001']

n1.is_active_output = True
n2.is_active_output = True

print(n1.is_active_output, n2.is_active_output)
FYI, bug reports that require the python console are sometimes a bit annoying, because I have to type/copy so much every time I want to reproduce it. Usually I end up preparing myself a file that just has a small script in it that I can just run to reproduce the bug. It doesn't matter too much, but if you happen to report similar bugs in the future, maybe consider writing a small(!) script instead of using the console. E.g. this is the script I used for this bug: ``` import bpy n1 = bpy.context.scene.world.node_tree.nodes['World Output'] n2 = bpy.context.scene.world.node_tree.nodes['World Output.001'] n1.is_active_output = True n2.is_active_output = True print(n1.is_active_output, n2.is_active_output) ```

This issue was referenced by 40cbbe809c

This issue was referenced by 40cbbe809c0afe83068cdca97992204d7b135b9e

This issue was referenced by 22a341d9d8

This issue was referenced by 22a341d9d8d3d337f79df228ab2e4e0726f81430
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
5 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#96292
No description provided.