Skip to content

Instantly share code, notes, and snippets.

@simonreeves
simonreeves / pysideDialogExamples.py
Created October 11, 2017 16:49 — forked from tcrowson/pysideDialogExamples.py
Examples of simple PySide dialogs
from PySide.QtGui import *
# create a modal message box with a single 'Ok' button
box = QMessageBox()
box.setWindowTitle('Title')
box.setText('Text')
box.exec_()
# create a modal message box that offers some choices (Yes|No|Cancel)
import sys
from Qt import QtCore
from Qt import QtGui
from Qt import QtCompat
from Qt import QtWidgets
class my_dialog(QtWidgets.QDialog):
def __init__(self):
QtWidgets.QDialog.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
@simonreeves
simonreeves / houdini_shelf_tool.py
Last active June 12, 2019 10:56
#houdini #python shelf tool for tab menu
# toolsutil part came from a built-in shelf tool so I could get the correct context pwd
import toolutils
pane = toolutils.activePane(kwargs)
new_node = pane.pwd().createNode('subnet', 'lights')
new_node.setColor(hou.Color(0.97, 0.8, 0.27))
new_node.setUserData('nodeshape', 'light')
@simonreeves
simonreeves / vex example.cc
Last active June 12, 2019 11:47
#houdini #vex #wrangle
// point wrangle using 'lage' attribute generated from L-System SOP
// looping over points is like doing a promote max sop
// get the max by looping over the points
float lage_max = 0;
// get point count
int pc = npoints(0);
// loop over points
@simonreeves
simonreeves / loop over points.c
Last active September 28, 2020 13:29
#houdini #vex
// get the max by looping over the points
int pc = npoints(0);
printf('pc %s\n', pc);
for(int i=0; i < pc; i++) {
// careful with printing on a large mesh
// printf('point: %s\n', i);
}
# get node's input parm
# like opinputpath('.')
hou.node('.').inputs()[0].parm('scale').eval() * hou.node('.').inputs()[0].parm('sx').eval()
def nulls_from_x():
for node in hou.selectedNodes():
print(node.name())
t = node.parmTuple('t').eval()
r = node.parmTuple('r').eval()
s = node.parmTuple('s').eval()
scale = node.parm('scale').eval()
new_null = hou.node('obj/').createNode('null')
new_null.parmTuple('t').set(t)
@simonreeves
simonreeves / houdini_redshift_console_log.py
Last active August 27, 2021 09:06
enable log in python #houdini #python #redshift
# Set log level to 'debug'
hou.hscript("Redshift_setLogLevel -L 5")
# Toggle Redshift console log
hou.hscript("Redshift_switchConsoleLog")
@simonreeves
simonreeves / houdini_vex_wrangle_get_distance_to_points.c
Last active February 6, 2024 22:37
get distance to points wrangle #houdini #vex #wrangle
// get nearest point index of second input
int np = nearpoint(1, @P);
// get that point's position
vector np_pos = point(1, 'P', np);
// measure distance
float dist = distance(@P, np_pos);
// normalise distance
# not complete but an example
def n():
# get child nodes from a node
prop_nodes = hou.node('/obj/action/props/').children()
# loop through children
for prop in prop_nodes:
# filter by name