WorkSpaceTool bl_icon trouble #68720

Open
opened 2019-08-16 10:20:48 +02:00 by Ivan Perevala · 4 comments

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.13

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: blender/blender@f6cb5f5449
Worked: (optional)

Short description of error
So. I create WorkSpaceTool class with my custom icon and register it. If I install the addon with this tool from zip file, icon moved to addon directory (C:\Users\Username\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\MyAddonName\icons\ops.generic.toolname.dat). But in the toolbar I have "None" icon. Ok, before calling

bpy.utils.register_tool

I use next lines:

    frpath = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
                          "PathTool", "icons", "ops.generic.toolname.dat")
    path = os.path.split(bpy.app.binary_path)[0]
    pathto = os.path.join(path, "2.80", "datafiles", "icons", "ops.generic.toolname.dat")

    if os.path.isfile(frpath) and (not os.path.isfile(pathto)):
        try:
            copyfile(frpath, pathto)
        except:
            print("Icon file not copied!")

to move icon to C:\Program Files\Blender Foundation\Blender\2.80\datafiles\icons. This operation can be done only if start Blender as administrator.
But why I can't search icon directly in the adon directory? Why user whu install my addon need to move one file by hands?

**System Information** Operating system: Windows-10-10.0.18362 64 Bits Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.13 **Blender Version** Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: `blender/blender@f6cb5f5449` Worked: (optional) **Short description of error** So. I create WorkSpaceTool class with my custom icon and register it. If I install the addon with this tool from zip file, icon moved to addon directory (C:\Users\Username\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\MyAddonName\icons\ops.generic.toolname.dat). But in the toolbar I have "None" icon. Ok, before calling ``` bpy.utils.register_tool ``` I use next lines: ``` frpath = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), "PathTool", "icons", "ops.generic.toolname.dat") path = os.path.split(bpy.app.binary_path)[0] pathto = os.path.join(path, "2.80", "datafiles", "icons", "ops.generic.toolname.dat") if os.path.isfile(frpath) and (not os.path.isfile(pathto)): try: copyfile(frpath, pathto) except: print("Icon file not copied!") ``` to move icon to C:\Program Files\Blender Foundation\Blender\2.80\datafiles\icons. This operation can be done only if start Blender as administrator. But why I can't search icon directly in the adon directory? Why user whu install my addon need to move one file by hands?
Author

Added subscriber: @ivpe

Added subscriber: @ivpe
Member

Added subscribers: @ideasman42, @lichtwerk

Added subscribers: @ideasman42, @lichtwerk
Campbell Barton was assigned by Philipp Oeser 2019-08-16 10:53:44 +02:00
Member

This is true, since the toolsystem always uses bpy.utils.system_resource('DATAFILES', "icons"), see _icon_value_from_icon_handle.

Since you already changed this from bug to TODO, I would kindly ask @ideasman42 about the design of this: how are addons supposed to provide their tool icons bundled? I think we can confirm this [I expect lots of addons wanting to do this]?
Should this be put on https://developer.blender.org/T63733?

This is true, since the toolsystem always uses `bpy.utils.system_resource('DATAFILES', "icons")`, see `_icon_value_from_icon_handle`. Since you already changed this from bug to TODO, I would kindly ask @ideasman42 about the design of this: how are addons supposed to provide their tool icons bundled? I think we can confirm this [I expect lots of addons wanting to do this]? Should this be put on https://developer.blender.org/T63733?
Author

Ok, thank you for feedback. I'm waiting

Ok, thank you for feedback. I'm waiting
Sign in to join this conversation.
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-addons#68720
No description provided.