This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import contextlib | |
@contextlib.contextmanager | |
def set_read_only_parm(parm): | |
if not isinstance(parm, (hou.Parm, hou.ParmTuple)): | |
return | |
# Unlock the parm | |
parm.lock(False) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Disable When / Hide When Expressions | |
Used to control parameter visibility. | |
""" | |
# Hide When Expression | |
{ expanded == 1 } | |
# Hide When Expression (multiparm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import hou | |
def ftrimify(parm): | |
"""Wrap an ftrim() function around channel refs. | |
Args: | |
parm (hou.Parm): Parameter to add ftrim()s to. Should be a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Match forearm, leftArm, and arm | |
@name=*[aA]rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toggle_manual(): | |
"""Toggle cook mode""" | |
current_mode = hou.updateModeSetting() | |
auto = (hou.updateMode.AutoUpdate, hou.updateMode.OnMouseUp) | |
toggle_cook = hou.shelves.tool("toggle_manual") | |
toggle_cook.setLabel("Auto Update") | |
if current_mode in auto: | |
hou.setUpdateMode(hou.updateMode.Manual) | |
toggle_cook.setIcon("MISC_cook") | |
elif current_mode == hou.updateMode.Manual: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Callbacks | |
idx = kwargs["script_multiparm_index"] | |
# In a parameter expression | |
idx = evaluatingParm().multiParmInstanceIndices[0] # Returns a tuple. Will need subscript for the right level, and test for IndexError | |
# In a parameter expression, better | |
import re | |
idx = re.match(r".+(\d+)$", evaluatingParm().name()).group(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import os | |
import re | |
def timedelta(file1, file2): | |
t1 = os.path.getmtime(file1) | |
t2 = os.path.getmtime(file2) | |
time = abs(t2 - t1) / 60.0 | |
min = math.floor(time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get packed xform and pivot | |
matrix xform = getpackedtransform(0, i@ptnum); | |
vector pivot = primintrinsic(0, "pivot", i@ptnum); | |
// Orient for instancing | |
p@orient = quaternion(matrix3(xform)); | |
// Crack pscale | |
vector scale = cracktransform(0, 0, 2, 0, xform); | |
f@pscale = avg(scale); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toolutils as tu | |
viewer = tu.sceneViewer() | |
viewports = viewer.viewports() | |
cam = hou.node("/obj/rendercam") | |
# There are always 4 viewports! | |
# https://www.sidefx.com/forum/topic/38171/#post-174454 | |
for vp in viewports: | |
vp.setCamera(cam) |
NewerOlder