Exploring Houdini R&D with Python for Massive Exporter Tool UI using hou module and PyQt

Posted by


Creating a custom tool in Houdini can greatly enhance your workflow and productivity. In this tutorial, we will focus on creating a Massive Exporter Tool using the Houdini R&D Python module and PyQt for the user interface.

Step 1: Setting up the project

  1. Open Houdini and create a new Python script in the Script Editor.
  2. Import the necessary modules:
    import hou
    from PyQt5 import QtWidgets, QtCore

Step 2: Creating the UI

  1. Define a class for the custom tool:

    class MassiveExporterToolUI(QtWidgets.QWidget):
    def __init__(self):
        super(MassiveExporterToolUI, self).__init__()
    
        self.initUI()
    
    def initUI(self):
        # Create a layout for the tool
        layout = QtWidgets.QVBoxLayout()
    
        # Add a label for the tool title
        title_label = QtWidgets.QLabel('Massive Exporter Tool')
        layout.addWidget(title_label)
    
        # Add a file browser button to select the export folder
        self.export_folder_btn = QtWidgets.QPushButton('Select Export Folder')
        self.export_folder_btn.clicked.connect(self.selectExportFolder)
        layout.addWidget(self.export_folder_btn)
    
        # Add a button to export the scene
        export_btn = QtWidgets.QPushButton('Export Scene')
        export_btn.clicked.connect(self.exportScene)
        layout.addWidget(export_btn)
    
        # Set the layout for the tool
        self.setLayout(layout)
    
    def selectExportFolder(self):
        # Function to open a file browser and select the export folder
        export_folder = QtWidgets.QFileDialog.getExistingDirectory(None, 'Select Export Folder')
        if export_folder:
            self.export_folder_btn.setText(export_folder)
    
    def exportScene(self):
        # Function to export the scene
        export_folder = self.export_folder_btn.text()
        selected_node = hou.node('/obj/').selectedItems()[0]
        selected_node.save(export_folder + '/' + selected_node.name() + '.obj')

Step 3: Displaying the UI

  1. Create an instance of the MassiveExporterToolUI class and show the tool:
    app = QtWidgets.QApplication([])
    tool_ui = MassiveExporterToolUI()
    tool_ui.show()
    app.exec_()

Now, when you run the script in the Script Editor, the Massive Exporter Tool UI will be displayed. You can select an export folder and export the selected node as an OBJ file.

This is just a basic example of creating a custom tool in Houdini using the Houdini R&D Python module and PyQt. You can expand on this by adding more functionality and customizing the UI to suit your needs. Experiment with different layouts, widgets, and functionalities to create a tool that fits your workflow.

0 0 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@DRCstill
2 months ago

Hi wei750830, thanks! The UI run in different thread inside Houdini in which let you manage both. Using QGraphicsPixmapItem in general QGraphicsItem under QGraphicsView provide real time info that can be used to manage the nodes.

@LaiLinus
2 months ago

THIS IS AMAZING……!!!
how do u grab the massive app GUI in realtime?!