0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Houdini × Python】 Shelf Toolsの Name,Label,アイコンをできるだけ自動入力しよう

0
Last updated at Posted at 2026-03-24

はじめに

Houdiniでモデリングするようになって
よく使うツールはShelf Toolsに登録しています

image.png

そのときに Name,Label,Icon の入力をするのが面倒なので自動化する仕組みを考えました

この仕組みを入れれば入力の一元管理ができます

実装方法と処理内容

Python ModuleにあるクラスからModuleを読み込んで
ツールの機能を表す、soptoolutils.genericToolの第二引数 name_genericTool = "polyfill"
に基づく文字列を Name,Label,Iconに入れる処理を実行しています

image.png

name_genericTool = "box"
name_genericTool = "sphere"

shelftool.utils.SHELF(kwargs).redefine_by_genelictool(name_genericTool, "SOP")

この第二引数contextが 動作名の頭につくことで
SOP_box
SOP_sphere
こういう名前がアイコン名になります

return f"{context.upper()}_{name_genericTool}"

"SOP" "SoP" "sOP"
upper()で全て大文字にしてます


Shelf ToolsのEdit in external editorを押すと外部エディタにコードが送られ、保存すればHoudiniに反映されます

image.png

コード

詳細

Edit Tool

import hou
import soptoolutils
import shelftool.utils #HoudiniのPython Module Pathから読み込み

import importlib
importlib.reload(shelftool.utils)


name_genericTool = "polyfill"


shelftool.utils.SHELF(kwargs).redefine_by_genelictool(name_genericTool, "sOP")
node: hou.SopNode = soptoolutils.genericTool(kwargs, name_genericTool)


"""
toolの初期設定を変更する場合は以降に記述
例
node.parm("mode").set(1)
"""

Python Module

shelftool/utils.py

import hou
from typing import Any


class SHELF:
    def __init__(self, kwargs: dict[str, Any]):
        self.name_tool = kwargs["toolname"]

    def redefine_by_genelictool(self, name_genericTool: str, context: str = None):

        tool = None

        for shelf in hou.shelves.shelves().values():
            for t in shelf.tools():
                if t.name() == self.name_tool:
                    tool = t
                    break
            if tool:
                break

        tool.setLabel(name_genericTool.title())
        tool.setName(name_genericTool)
        tool.setIcon(self._build_name_icon(name_genericTool, context))

    def _build_name_icon(self, name_genericTool, context: str = None) -> str:

        if context:
            return f"{context.upper()}_{name_genericTool}"

        return "PLASMA_App"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?