No More Retake

3DCG屋さん向けTips&Referenceサイト

メニュー

Houdini Custom:OPmenu

OPmenuというファイルを用いると、ノードの右クリックメニューを追加できる。

Hoduini_Cusotom_v003

以前書いたFBresと同様、Houdini起動時に、環境変数HOUDINI_PATHで指定されたパスにあるOPmenuファイルを参照します(たぶん)
HOUDINI_PATHが設定されていなければ、$HOME/houdinixx.xを参照します(たぶん)
(デフォルトだとHOUDINI_PATHは設定されてなかった気がします)
($HOMEはwindowsの場合は、”C:\Users\<username>\Documents\”かな)

参照先のパスに、OPmenuファイルがない場合は、”Opmenu”ファイルを作成して中身書きます(拡張子なし)
$HHにファイルフォーマットの参考があります。
($HHは、Houdiniインストールパス以下にあるhoudiniディレクトリのこと、$HFS/houdiniと同義)

ためしに、$HHにあるOPmenuを開いてみるとこんなかんじ。


# This file allows you to add menu items to the RMB popup menu for various
# operator types. Each line consists of four entries:
# 1. The operator type name. This can include wildcards.
# 2. The hotkey name. This should be a single unique word.
# 3. The menu item text.
# 4. The path to the script to run when the menu item is chosen.
# The script path can be specified relative to the OPmenu file.
# When the script is run, the full path of the node for which the menu item
# was chosen is passed as the first argument.
#
# The first argument can also start with the keyword "Expr:". If so, the rest
# of the first argument is treated as an expression that gets evaluated when
# the menu is brought up. If the expression evaluates to the string "1", then
# the menu item will appear. Two local variables are defined when executing
# this expressions: $opmenu_optype is the operator table and type name (such
# as "Object/geo"). $opmenu_oppath is the full path name to the node that is
# bringing up the menu (such as "/obj/light1").

# The following line adds a script called "killkids.cmd" to all objects:
# "Pop/* Sop/*" killkids "Kill All Child Nodes" ./scripts/killkids.cmd
# The following line adds a script called "reversein.cmd" to the Merge SOP:
# Sop/merge reverseinputs "Reverse Inputs" /tmp/reversein.cmd
# The following line adds a script only to a node named "/obj/model":
# 'Expr: strcmp($opmenu_oppath, "/obj/model") == 0' model "Model" /tmp/foo.cmd
# The following line adds a script to any op defined in an OTL
# (note that an entry can be continued on the next line by placing a backslash
# at the end of the line):
# 'Expr: execute("otgetotl -b $opmenu_optype")' \
# isinotl "In an OTL" /tmp/foo.cmd

なんじゃこりゃ(゚〇゚;)、英語ばっか。

意訳した。
以下はそれ!


 

OPmenuファイルは右クリック時のポップアップメニューを追加するファイルです。
各行4つの事項から構成されます。
1:オペレータのタイプ名(ワイルドカード * もOK)
2:ホットキー名(これはuniqueな一単語)
3:メニューアイテム名(メニューに表示される名前)
4:メニューが選ばれた時に実行するスクリプトのパス

スクリプトのパスはOPmenuファイルからの相対パスでもいい。
スクリプトが実行されたとき、選択していたノードのフルパスが引数として渡されます。
引数は”Expr:”ってキーワーを使うとエクスプレッションを組めて、それが1の時、menuに表示することができる。
エクスプレッション実行時2つのローカル変数が定義される。
$opmenu_optype・・・オペレータのタイプ名(例:”Object/geo”)
$opmenu_oppath・・・右クリックメニューを開いたノードのフルパス(例:”/obj/light1″)

以下例文

“killkids.cmd”ってスクリプトをすべてのジオメトリに追加した例


"Pop/* Sop/*" killkids "Kill All Child Nodes" /home/v-abe/houdini12.5/scripts/yes.cmd

 

“reversein.cmd”スクリプトをMerge SOPに追加した例


Sop/merge reverseinputs "Reverse Inputs" /tmp/reversein.cmd

 

“/obj/model”って名前のノードにだけスクリプトを追加した例


'Expr: strcmp($opmenu_oppath, "/obj/model") == 0' model "Model" /tmp/foo.cmd

 

OTLで定義したオペレーションタイプにスクリプトを追加した例


'Expr: execute("otgetotl -b $opmenu_optype")' /isinotl "In an OTL" /tmp/foo.cmd

スクリプトはHscript(.cmd)

自分でなんか例を載っけようかと思ったけど、こんだけサンプルあったら十分。

以上!

間違い等ありましたらご指摘を!


2017/04/12追記

最近のバージョンではXMLで書くのだとか。
http://www.sidefx.com/docs/houdini/basics/config_menus.html

 

関連記事

  1. 2018.04.09

    Houdiniの本!!

コメントをお待ちしております

このサイトについて

3DCG Tipsサイト。Houdiniの記事が多めです。

RSS

follow us in feedly

Archives

  • 2024 (1)
  • 2023 (2)
  • 2022 (9)
  • 2021 (14)
  • 2020 (46)
  • 2019 (17)
  • 2018 (33)
  • 2017 (29)
  • 2016 (36)
  • 2015 (64)
  • 2014 (54)
  • 2013 (60)
  • 2012 (55)

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

Houdiniを使えるようになる本


Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.facebook.com/restserver.php?method=links.getStats&urls=http%3A%2F%2Fnomoreretake.net%2F2016%2F03%2F28%2Fhoudini_cusotom_opmenu%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http%3A%2F%2Fnomoreretake.net%2F2016%2F03%2F28%2Fhoudini_cusotom_opmenu%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132