Houdini 19.5 サンプル Pythonパネルのサンプル

ノードパス

現行ノードパスの変更を検知する方法。

Example

このサンプルでは、現行ノードパスの変更を検知できるようにするために、Python Panelコード内にonNodePathChanged(node)フックを実装しています。

別のノードを選択してみると、Python Panelがその現行ノードに追従しているのがわかります。

<?xml version="1.0" encoding="UTF-8"?>
<pythonPanelDocument>
  <!-- This file contains definitions of Python interfaces and the
 interfaces menu.  It should not be hand-edited when it is being
 used by the application.  Note, that two definitions of the
 same interface or of the interfaces menu are not allowed
 in a single file. -->
  <interface name="NodePathExample" label="Node Path Example" icon="hicon:/SVGIcons.index?DATATYPES_node_path.svg" showNetworkNavigationBar="true" help_url="">
    <script><![CDATA[from hutil.Qt import QtWidgets

class NodePathExample(QtWidgets.QWidget):
    def __init__(self):
        super(NodePathExample, self).__init__()

        instruction_label = QtWidgets.QLabel(
            "Please navigate the Houdini node network using the network editor.")

        self.currentNodePathLabel = QtWidgets.QLabel()

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(instruction_label)
        layout.addSpacing(5)
        layout.addWidget(self.currentNodePathLabel)
        layout.addStretch(1)

        self.setLayout(layout)

    def updateCurrentNodePathLabel(self, node_path):
        self.currentNodePathLabel.setText("Current Node Path: %s" % node_path)

theExampleWidget = NodePathExample()

def onCreateInterface():
    global theExampleWidget
    return theExampleWidget

def onNodePathChanged(node):
    global theExampleWidget

    if node:
        node_path = node.path()
    else:
        node_path = "None"
    theExampleWidget.updateCurrentNodePathLabel(node_path)

 ]]></script>
    <includeInToolbarMenu menu_position="102" create_separator="false"/>
    <help><![CDATA[]]></help>
  </interface>
</pythonPanelDocument>

Pythonパネルのサンプル

  • Custom Graphics

    Python Panelでの独自のOpenGL描画。

  • Qt Designer

    Qt Designerファイルからユーザインターフェースレイアウと読み込む方法。

  • Qtイベント

    Python PanelsからQtイベントをリッスンする方法。

  • Viewport Color Editor

    ビューポートのカラーを編集するためのPySideインターフェース。

  • ドラッグアンドドロップ

    Python Panelでドラッグアンドドロップの機能を実装する方法。

  • ノードパス

    現行ノードパスの変更を検知する方法。

  • パラメータのリンク

    PySideパラメータウィジェット(つまり、テキストフィールドとスライダ)をHoudiniのノードパラメータへリンク、またはその逆のリンクの付け方。