[PYTHON] Use PySide for HDA UI

Overview

Starting with Houdini 18.0, you can use PySide for the HDA UI. For example, it is possible to create a tool to list and assign materials using such a list view. MatBrowser.gif

Method

Use the Python Panel Editor to make the HDA UI PySide. The following page will be helpful for the Python Panel Editor.

-Create a custom UI with Houdini Python Panel -Python Panel Editor (Official) -Python panel sample (official)

What is written above is to incorporate the PySide UI into the Houdini panel, but to apply it to HDA, check ** Show in Parameters Pane ** and enter the operator name in the ** For Operators ** column. To specify.

The operator name should be ** / ** or ** :: / ** if the HDA is prefixed as shown in the image. I will.

After that, if you create a node from the tab menu, it will be displayed with the PySide UI applied.

important point

Please note that this Python Panel file itself must be placed in a readable location. Basically, put it in either of the following, and HDA will be automatically loaded if you put it in the ** otls ** folder of the parent hierarchy.

By the way, the code used for Python Panel Editor can also be used with tools supported by PySide such as Maya. In the case of this tool, it is necessary to rewrite the part to which the material is applied, but since the other parts can be used in common, it can be reused.

Switch to normal UI

You can switch the UI display to PySide or normal by pressing the button in the figure.

By the way, the normal UI of Material Browser is like this. It's as simple as the path to the group and material. In HDA, even if the UI is set to PySide, parameter information can usually be obtained only from the UI, so the command executed from PySide creates a material in HDA and uses the selected surface and material path as parameters. We are doing the process of setting.

problem

Originally, if you want to get the HDA node itself with Python, you will use ** hou.pwd () ** and ** kwargs ['node'] **, but you can not get it on the PySide side. Hmm. If you can't do this, you won't be able to specify which node to target when applying the material.

I did not find a solution to this problem, so this is just the method I thought of, but I have registered the following scripts in ** OnCreated ** and ** OnLoaded ** of HDA.

def set_current_node(node, event_type, **kwargs):
    hou.setPwd(node)
node = kwargs['node']
node.addEventCallback((hou.nodeEventType.AppearanceChanged, ), set_current_node)

** OnCreated ** is a script that is executed when an HDA is created, and ** OnLoaded ** is a script that is executed when a scene file is opened.

Here, ** addEventCallback ** sets this HDA to the current node when the node state (selection, flags, etc.) changes. It's pretty aggressive, but you can get an HDA node from PySide with ** hou.pwd () **.

If you know a better way, please let me know ...

Summary

This is how to use PySide for HDA UI.

We haven't responded yet, so there is almost no information or implementation examples, but the range of things you can do with HDA will increase, so please try it.

By the way, I'm planning to change the HDA UI from Houdini to PySide, which publishes models for games.

Recommended Posts

Use PySide for HDA UI
One for Maya UI
Pandas / DataFrame Tips for practical use
Use Jinja2 for PasteScript template engine
Next, use Python (Flask) for Heroku!
Use numpy.ndarray for multiple length evaluation
Survey for practical use of BlockChain
Beginners use Python for web scraping (1)
Beginners use Python for web scraping (4) ―― 1
Use Azure AD for Linux authentication
Use cases for nested function definitions