Unable to use custom icon as bl_icon for Custom Node Tree #85213

Closed
opened 2021-01-29 21:47:13 +01:00 by Zach Eastin · 6 comments

System Information
Operating system: Windows 10
Graphics card: Nvidia RTX 2080 ti

Blender Version
Broken: 2.83.10
Worked: Not sure if ever worked

Short description of error
When setting the icon for a custom node tree you can only set it to the blender icons. It seems like the node tree is loaded or checked before it is registered as the variable custom_icons always is called before it can be assigned as an image preview.

Exact steps for others to reproduce the error
Based on the attached .blend file just try to install and enable the addon. Depending on what is commented out the error will either say
'NoneType' object is not subscriptable if custom_icons is set to None initially
or
KeyError: 'logo' if custom_icons is set to bpy.utils.previews.new() initially

IconTest.zip

**System Information** Operating system: Windows 10 Graphics card: Nvidia RTX 2080 ti **Blender Version** Broken: 2.83.10 Worked: Not sure if ever worked **Short description of error** When setting the icon for a custom node tree you can only set it to the blender icons. It seems like the node tree is loaded or checked before it is registered as the variable `custom_icons` always is called before it can be assigned as an image preview. **Exact steps for others to reproduce the error** Based on the attached .blend file just try to install and enable the addon. Depending on what is commented out the error will either say `'NoneType' object is not subscriptable` if `custom_icons` is set to `None` initially or `KeyError: 'logo'` if `custom_icons` is set to `bpy.utils.previews.new()` initially [IconTest.zip](https://archive.blender.org/developer/F9604369/IconTest.zip)
Author

Added subscriber: @Zeastin

Added subscriber: @Zeastin

Added subscriber: @rjg

Added subscriber: @rjg

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

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

For bl_icon you have to assign a valid enum as listed in the Python API docs .

'NoneType' object is not subscriptable if custom_icons is set to None initially

If you assign None to a variable and then try to access it like and array that results in this error

KeyError: 'logo' if custom_icons is set to bpy.utils.previews.new() initially

If there is no entry with the key logo then this is the error you will see. Initially the collection doesn't contain any entry.

If you need help learning or using Blender, please post a question on one of our [community websites ]], for instance https:*blender.stackexchange.com/ , https:*blenderartists.org/ or the [ https:*blender.chat/channel/support | #support channel on Blender chat . The bug tracker is only for bug reports.

For `bl_icon` you have to assign a valid enum as listed in the [Python API docs ](https://docs.blender.org/api/current/bpy.types.NodeTree.html#bpy.types.NodeTree.bl_icon). > 'NoneType' object is not subscriptable if custom_icons is set to None initially If you assign `None` to a variable and then try to access it like and array that results in this error > KeyError: 'logo' if custom_icons is set to bpy.utils.previews.new() initially If there is no entry with the key `logo` then this is the error you will see. Initially the collection doesn't contain any entry. If you need help learning or using Blender, please post a question on one of our [community websites ]], for instance [[ https:*blender.stackexchange.com/ | Blender's StackExchange ]], [[ https:*blenderartists.org/ | blenderartists.org ]] or the [[ https:*blender.chat/channel/support | #support channel on Blender chat ](https:*www.blender.org/community/). The bug tracker is only for bug reports.
Author

@rjg Thank you for your response!
Apologies, but this would seem like unexpected behavior since almost everywhere else you can add an icon you can also add a custom icon even if it is an icon_value.
And the reason I added it as a bug was due to the seeming brain dead obvious errors in that no matter what I initially assigned to custom_icons it is never given anything before the Node Tree tries to access it. In the addon I included in my message you might have noticed that custom_icon should be filled before it is referenced by bl_icon. I was not seeking help in learning. Thank you for your time

@rjg Thank you for your response! Apologies, but this would seem like unexpected behavior since almost everywhere else you can add an icon you can also add a custom icon even if it is an icon_value. And the reason I added it as a bug was due to the seeming brain dead obvious errors in that no matter what I initially assigned to `custom_icons` it is never given anything before the Node Tree tries to access it. In the addon I included in my message you might have noticed that `custom_icon` should be filled before it is referenced by bl_icon. I was not seeking help in learning. Thank you for your time

@Zeastin the errors you are getting are entirely unrelated to whether bl_icon allows to assign a custom icon. Even if it would be supported the script wouldn't work. In both variations the variable doesn't contain the data you're expecting at the time it is accessed, hence the error message that one time it is None and thus you can't access it with an index, and the other time because the collection doesn't contain an entry with the key logo. If it is unclear to you why that is the case, then please create a question on Blender's Stack Exchange , post a link to it here and I will try to answer it.

@Zeastin the errors you are getting are entirely unrelated to whether `bl_icon` allows to assign a custom icon. Even if it would be supported the script wouldn't work. In both variations the variable doesn't contain the data you're expecting at the time it is accessed, hence the error message that one time it is `None` and thus you can't access it with an index, and the other time because the collection doesn't contain an entry with the key `logo`. If it is unclear to you why that is the case, then please create a question on [Blender's Stack Exchange ](https://blender.stackexchange.com/), post a link to it here and I will try to answer it.
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
2 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#85213
No description provided.