I have developed a little addon that provides icon button in the node editor. We have 80 node items. And so i have 80 external icons to load. I use custom_icons.load for that.

The problem is, every icon loads one by one when activating the tab. You see them popping up one after another. The user has to wait until all the icons are loaded. And that's for our 80 icons around 10 seconds in Blender 2.78a. Not good.

Is there a way to load the external icons at Blender startup? If not, is there a way to load at least all icons at once?

The script is already a init.py, Examplecode looks like this. The icons are of course missing. Please add a folder called icons besides the script, and put two png images into the folder with the correct name:

import bpy
import os
import bpy.utils.previews

class NodesIconPanel(bpy.types.Panel):
"""Creates a Panel"""
bl_label = "All Nodes"
bl_idname = "nodes.common_buttons"
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'TOOLS'
bl_category = "All Nodes"

@staticmethod
def draw(self, context):
layout = self.layout
default_context = bpy.app.translations.contexts.default

##### --------------------------------- Layout ------------------------------------------- ####

layout.label(text="Layout:")

row = layout.row()
row.alignment = 'LEFT'

props = row.operator("node.add_node", text="", text_ctxt=default_context, icon_value = custom_icons["icon32_frame"].icon_id)
props.use_transform = True
props.type = "NodeFrame"

props = row.operator("node.add_node", text="", text_ctxt=default_context, icon_value = custom_icons["icon32_reroute"].icon_id)
props.use_transform = True
props.type = "NodeReroute"

# global variable to store icons in
custom_icons = None

def register():

bpy.utils.register_class(NodesIconPanel)

# Our external Icons
global custom_icons

custom_icons = bpy.utils.previews.new()

#icons_dir = os.path.join(os.path.dirname(__file__), "icons")

# Use this for testing the script in the scripting layout
script_path = bpy.context.space_data.text.filepath
icons_dir = os.path.join(os.path.dirname(script_path), "icons")

def unregister():
global custom_icons
bpy.utils.previews.remove(custom_icons)
bpy.utils.unregister_class(NodesIconPanel)

# This allows you to run the script directly from blenders text editor
# to test the addon without having to install it.

if __name__ == "__main__":
register()

• I have the exact issue with the custom icons. Did you ever find a solution for this? I assume that the icons loaded from file need to be converted to textures and sent to the GPU which is why it takes so long. If this process could be done before hand (perhaps when the add-on is loaded/registered) it would eliminate the lag. – DolphinDream Feb 18 '17 at 22:04
• Unfortunately not, sorry. – Tiles Feb 19 '17 at 8:47
• I see it's been 3 years since last comment. Did you finally find something? – Simonetos The Greek Dec 1 '20 at 8:41
• No, sorry. Still not. – Tiles Dec 1 '20 at 10:34