忘却まとめ

Blenderの中級者・上級者向けの踏み込んだ情報や、アドオン・3DCGに関する情報を記事にします

ワークスペースツールのアイコン名を取得する方法【Blender Python】

Blender

投稿日:

Blenderでは、ワークスペースツールのアイコン名はわかりやすい場所に開示されていないので、調べる必要がある。

AIエージェントに聞いただけではどうもうまく取得できなかったので、ここに書き残す。

コード

下記の例では、UVエディターのワークスペースツールのアイコンを一覧表示する。

import bpy

from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
cls = ToolSelectPanelHelper._tool_class_from_space_type('IMAGE_EDITOR')

# 現在のコンテキストからUV/画像エディターのエリアとスペースを検索
area = next((a for a in bpy.context.screen.areas if a.type == 'IMAGE_EDITOR'), None)

if area:
    space = area.spaces.active
    # コンテキストを一時的にオーバーライドして、tools_from_context を実行
    with bpy.context.temp_override(area=area, space_data=space):
        for item_group in cls.tools_from_context(bpy.context):
            if type(item_group) is tuple:
                if item_group:
                    index_current = cls._tool_group_active.get(item_group[0].idname, 0)
                for sub_item in item_group:
                    if sub_item is not None:
                        print(f"{sub_item.label}: {sub_item.icon}")
            else:
                if item_group is not None:
                    print(f"{item_group.label}: {item_group.icon}")
else:
    print("UV/画像エディター(IMAGE_EDITOR)が開かれていない。")

結果

Tweak: ops.generic.select
Select Box: ops.generic.select_box
Select Circle: ops.generic.select_circle
Select Lasso: ops.generic.select_lasso
Cursor: ops.generic.cursor
Move: ops.transform.translate
Rotate: ops.transform.rotate
Scale: ops.transform.resize
Transform: ops.transform.transform
Annotate: ops.gpencil.draw
Annotate Line: ops.gpencil.draw.line
Annotate Polygon: ops.gpencil.draw.poly
Annotate Eraser: ops.gpencil.draw.eraser
Rip Region: ops.mesh.rip
Grab: brush.uv_sculpt.grab
Relax: brush.uv_sculpt.relax
Pinch: brush.uv_sculpt.pinch

参考

How to get toolbar icons names? - Archive / Python API - Developer Forum

-Blender

Copyright© 忘却まとめ , 2026 All Rights Reserved Powered by STINGER.