Houdini 20.0 Python scripting hou hou.qt

hou.qt.mimeType module

Enumeration of Houdini MIME types used to identify data in drag-and-drop operations.

On this page

Values

hou.qt.mimeType.asset

application/sidefx-houdini-asset.gallery.entry

An identifier to an asset from the asset gallery.

hou.qt.mimeType.channelPath

application/sidefx-houdini-channel.path

Full path to an animation channel. The node path and animation channel name are separated by a slash.

hou.qt.mimeType.chopTrackPath

application/sidefx-houdini-chop.track.path

Full path to an animation track. The CHOP node path and track name are separated by a space.

hou.qt.mimeType.galleryEntry

application/sidefx-houdini-gallery.entry

A gallery entry object.

hou.qt.mimeType.galleryEntryName

application/sidefx-houdini-gallery.entry.name

Name of a gallery entry.

hou.qt.mimeType.itemPath

application/sidefx-houdini-item.path

Full path to an item in the network view. For example, an item can be a network box.

hou.qt.mimeType.nodeFlagPath

application/sidefx-houdini-node.flag.path

Full path to a node flag. The node path and flag name are separated by a slash.

hou.qt.mimeType.nodePath

application/sidefx-houdini-node.path

Full path to a node.

hou.qt.mimeType.orboltNodeTypeName

application/sidefx-houdini-orbolt.node.type.name

Name of a node type installed from the Orbolt store.

hou.qt.mimeType.paneTabName

application/sidefx-houdini-pane.tab.name

Name of a pane tab.

hou.qt.mimeType.parmPath

application/sidefx-houdini-parm.path

Full path to a node parameter. The node path and parameter name are separated by a slash.

hou.qt.mimeType.persistentHandleName

application/sidefx-houdini-persistent.handle.name

Name of a persistent handle.

hou.qt.mimeType.primitivePath

application/sidefx-houdini-primitive.path

Full path to a geometry primitive. The SOP node path and primitive name are separated by a colon.

For example, /obj/foo/mysop:/alembic/foo/prim.

hou.qt.mimeType.shelfName

application/sidefx-houdini-shelf.name

Name of a shelf.

hou.qt.mimeType.shelfToolName

application/sidefx-houdini-shelf.tool.name

Name of a shelf tool.

hou.qt.mimeType.takeName

application/sidefx-houdini-take.name

Name of a take.

hou.qt.mimeType.usdPrimitivePath

application/sidefx-houdini-usd.primitive.path

Full path to a USD primitive.

hou.qt.mimeType.usdPrimitivePython

application/sidefx-houdini-usd.primitive.python

Python expression to access a USD primitive from a LOP node.

hou.qt.mimeType.usdPropertyPath

application/sidefx-houdini-usd.property.path

Full path to a USD property.

hou.qt.mimeType.usdPropertyPython

application/sidefx-houdini-usd.property.python

Python expression to access a USD property from a LOP node.

Examples

Use hou.qt.mimeType values in Qt widgets to accept different types of dropped Houdini data.

For example:

def dropEvent(self, event):
    mime_data = event.mimeData()

    # Check if a node path was dropped.
    data = mime_data.data(hou.qt.mimeType.nodePath)
    if not data.isEmpty():
        node_path = str(data)

        print "Dropped node path:", node_path
        return

    # Check if a parameter path was dropped.
    data = mime_data.data(hou.qt.mimeType.parmPath)
    if not data.isEmpty():
        parm_path = str(data)

        print "Dropped parameter path:", parm_path
        return

    # Default to plain text stored in the MIME data.
    print "Dropped text:", mime_data.text()

Note

It is possible for multiple pieces of data to be contained in a drag-and-drop operation for a specific Houdini MIME type. The tab character is used as a separator for the data.

Here is an example of handling multiple pieces of data:

def dropEvent(self, event):
    mime_data = event.mimeData()

    if not data.isEmpty():
        # Note that we split the string data because there could be multiple
        # node paths separated by tabs.
        node_paths = str(data).split("\t")

        print "Dropped node path(s):", node_paths
        return

    data = mime_data.data(hou.qt.mimeType.parmPath)
    if not data.isEmpty():
        # Note that we split the string data because there could be multiple
        # parameter paths separated by tabs.
        parm_paths = str(data).split("\t")

        print "Dropped parameter path(s):", parm_paths
        return

    print "Dropped text:", mime_data.text()

When starting a drag-and-drop operation from a Qt widget you can set data for specific Houdini MIME types. Some native Houdini widgets perform different drop actions depending on the MIME type of the data that is dropped.

Here is an example of starting a drag-and-drop operation and storing a Houdini node path in the drag object:

def mouseMoveEvent(self, event):
    # We only start a drag operation if certain conditions are met 
    # (i.e. LMB is pressed, mouse moved past a minimum distance).
    # In this example, we check for those conditions by checking a fictional
    # `self.should_start_drag` member variable.
    if self.should_start_drag:
        drag = QtGui.QDrag(self)
        mime_data = QtCore.QMimeData()

        # Store a node path in the MIME data.
        node = hou.node("/obj/myNode")
        mime_data.setData(hou.qt.mimeType.nodePath, node.path())

        # We also store the node path for the plain text MIME type as a default
        # for any widgets accepting generic text drops.
        mime_data.setText(node.path())

        # Start the drag-and-drop operation.
        drag.setMimeData(mime_data)
        drag.exec_()

You can also pass multiple pieces of data for Houdini-specific MIME types by using the tab character as a separator.

For example:

def mouseMoveEvent(self, event):
    if self.should_start_drag:
        drag = QtGui.QDrag(self)
        mime_data = QtCore.QMimeData()

        # Store multiple node paths in the MIME data.
        node1 = hou.node("/obj/myNode1")
        node2 = hou.node("/obj/myNode2")
        node3 = hou.node("/obj/myNode3")
        node_paths = [node1.path(), node2.path(), node3.path()]
        str_node_paths = "\t".join(node_paths)
        mime_data.setData(hou.qt.mimeType.nodePath, str_node_paths)

        # We also store the node paths for the plain text MIME type as a default
        # for any widgets accepting generic text drops.
        mime_data.setText(str_node_paths)

        # Start the drag-and-drop operation.
        drag.setMimeData(mime_data)
        drag.exec_()

hou.qt