Marc-André Belzile


About Me

Not Specified
Not Specified


Recent Forum Posts

[ViewerState] Bezier Spline custom workflow study April 29, 2019, 4:52 p.m.

1. Display-only geometry. How to use geometry for display only, not as object data? For instance, I generate geometry in the subnetwork to visualize the tangents, but I don't want them to be listed in geometry spreadsheet. I may need to manually call some render line function, but I don't see where/how.

2. Custom handles. I use the curvepoint handle, but I would like to set per control point shape and color. And curvepoint does not trigger onHandleToState when moving points around, etc. Is it possible to build its own handle? It might be solved by the previous question, but is there an “official” way to do so?

3. Multiple tools. I have different ways of interacting with my spline: adding points, moving points, selecting points, etc. Should I implement them in a single viewer state, using button parameters to switch tool, or is it more idiomatic to write several viewer states? The current implementation uses the former.

4. When a click triggers onMouseEvent, how to detect that it hit a handle? I would like to have behavior such as “add a point at the click position unless it was a click on the translate handle”.

5. Handle activation. How to deactivate (hide) a handle in onStateToHandle? For translate node, I went for the hacky “tx = 99999.9”. For the curvepoint handle, I tried to set the pointlist parameter to an empty string but it “breaks” it, namely when I switch the value back to a non empty string, the handle remains invisible unless I deselect-reselect the node.

6. Selection. Should I rely on houdini's selection mechanism to select the points I want my handle to move around, or should I implement my own selection process?

#1 There is no line API in the `HOM`, you need to use `hou.Drawable` and `houSopVerbs` for creating guide geometries that won't show up as scene elements (see post above). If you want to draw the curve while holding the mouse you could probably do it by multiplying the `start` and `end` drawable transform with the line length in your `mouse event` handler. But this is mostly a hack. I think the right way would be to create (or update) the line verb in the `mouse event` handler with different parameters and set the drawable with the new geo. Something I could look into.

#2 We don't have custom handles yet (it's in the plan though), I'll have to look at the `curvepoint` issue.

#3 Unfortunately, multiple states are not available yet (also planned). In the meanwhile you need to implement your tools in one single state and use a hotkey, popupmenu or key events (H17.5) to activate individual tool.

#4 state events are processed only if the handle hasn't consumed the event. If the handle is under the mouse, then it gets the mouse event first (if the handle is enabled of course). If it doesn't processed it, then it falls through to the state. Most handles don't actually consume a click, but a press and drag. This is why you can still select a geometry though a handle in Houdini. I think you should just assume that if the state mouse handler gets the event it means the handler hasn't consumed it and the state should just process it.

#5 You can use the `hou.Handle` object to show/hide/trigger an handle. This object is available in H17.5.

#6 You could probably just use the Houdini selection by holding ‘S’ and get the selected elements via the `onResume` handler. Or you can register your own python state selector and implement the `OnSelection` callback. Once you have a selector registered, the user can either use the Houdini selection with ‘S’ or the python state selector. In both case, the `OnSelection` callback is called with the selected element(s).

[ViewerState] Bezier Spline custom workflow study April 29, 2019, 10:08 a.m.

Hi, I'm interested too on how to draw simple line in state mode display only, that is not a sop geometry.
Let's say (pseudo code) onMouseEvent click 1 draw line vertex 0 and on second click vertex 1?
The documentation seems detailed, but it's kinda convoluted a bit.

You can use hou.Drawable along with hou.SopVerbs, the resulting geometry will not be part of the scene.

        # Measure Line 1
        self.guide_geo1 = hou.Geometry()
        line_verb = hou.sopNodeTypeCategory().nodeVerb("line")

            "origin": self.startpos,
            "dir": hou.Vector3(0,1,0),
            "dist": 1

        line_verb.execute(self.guide_geo1, [])

        self.drawable1 = hou.Drawable(self.scene_viewer, self.guide_geo1, "guide_1")

        # Measure Line 2
        self.guide_geo2 = hou.Geometry()
        line_verb = hou.sopNodeTypeCategory().nodeVerb("line")

            "origin": self.startpos,
            "dir": hou.Vector3(0,1,0),
            "dist": 1

        line_verb.execute(self.guide_geo2, [])

        self.drawable2 = hou.Drawable(self.scene_viewer, self.guide_geo2, "guide_2")

How to make a password control in Houdini? April 2, 2019, 12:33 p.m.


Following Michael's suggestion, here's a little demo for implementing a tool password dialog with python

import hou
from PySide2 import QtWidgets
from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton

class PasswordDialog(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("Type a password")
        pw = QtWidgets.QLineEdit()

        vlayout =  QtWidgets.QVBoxLayout()        
pwd= PasswordDialog(hou.ui.mainQtWindow())