Saturday, November 18, 2017

Houville :: iterating in VEX

Urgh, I keep forgetting this. So to iterate in VEX:
//fix negative colours per channel
for ( int i = 0; i < int (3); i++)
{
    if (@Cd[i] < 0) { @Cd[i] *= -1;}
}

Thursday, October 26, 2017

Houville :: customising node attributes

Create a text file called "OPcustomize" in your houdini16.0 (or corresponding) folder. Here you can describe the new defaults you want to use with your nodes. For colours
opdefaultcolor Sop null 'RGB 0.0 0.0 0.0';
opdefaultcolor Sop dopnet 'RGB 0.5 0.0 0.0';
opdefaultcolor Sop dopimport 'RGB 0.5 0.0 0.0';
opdefaultcolor Sop object_merge 'RGB 0.475 0.812 0.204';
Thanks to Amber for this one.

Going beyond this:

We can grab the type from a python shell with drag-drop then append ".type()". And we can also work with default and user-defined shapes, and grab the colour info.
# good if you manually selected a new shape.
n.userData("nodeshape");

# good for finding the session default shape for the node
n.type().defaultShape();

# for getting the colour that has been user assigned
n.color()


Example:
opdefaultcolor Driver null 'RGB 0.478 0.478 0.478';
opdefaultshape Driver null 'circle';
opdefaultcolor Driver merge 'RGB 0.65 0.65 0.65';
opdefaultshape Driver merge 'circle';
opdefaultcolor Driver geometry 'RGB 0.145 0.667 0.557';
opdefaultshape Driver geometry 'tabbed_left';

opdefaultcolor Driver gridmarkets::render_submit::1.5.2 'RGB 0.45 0.12 0.6';
opdefaultcolor Driver gridmarkets::nuke::1.19 'RGB 0.976 0.78 0.263';

opdefaultcolor Driver gridmarkets::transcode::1.8 'RGB 0.25 0.5 1';
opdefaultshape Driver gridmarkets::transcode::1.8 'wave';
opdefaultcolor Driver ifd 'RGB 1 .976 0.666';

opdefaultcolor Sop null 'RGB 0.0 0.0 0.0';
opdefaultcolor Sop dopnet 'RGB 1 0 0';
opdefaultcolor Sop gridmarkets::cloud_cache::1 'RGB 0.145 0.667 0.557';
opdefaultshape Sop gridmarkets::cloud_cache::1 'tabbed_left';
opdefaultcolor Sop file 'RGB 0.616 0.871 0.769';

Thursday, September 7, 2017

Houville :: how to not go insane with Nuke vs Houdini hotkeys

Display shortcuts: I have these set as F9-F12
import os,glob
def visualise(flag):
    if flag ==1: hou.selectedNodes()[0].setDisplayFlag(1)
    if flag ==2: hou.selectedNodes()[0].setRenderFlag(1)
    if flag ==3:
        if len(hou.selectedNodes())>0:
            state = 1-hou.selectedNodes()[0].isTemplateFlagSet()
            for i in hou.node(os.path.dirname(hou.selectedNodes()[0].path())).glob('*'): i.setTemplateFlag(0)
            for i in hou.selectedNodes():
                i.setTemplateFlag(state)
    if flag ==4:
        state = 1-hou.selectedNodes()[0].isBypassed()
        for i in hou.selectedNodes():
            i.bypass(state)

visualise(4)


This is straight out of Nukeland for snapping your nodes to the grid intersections. I have it set as Shift+\
offsetDict = {'Sop alembic':[0.0, 0.21440000000000037],'Sop merge':[-0.0011499999999999844, -0.021300000000000013], 'Object hlight::2.0':[0.002100000000000435, -0.0016000000000002679],'Object envlight':[0.002100021578371525, -0.0015999939292665744], 'Object null':[0.0, -0.005000004917383172], 'Object cam':[0,-0.045350006222724976]}

def tidyNodes(nodes=hou.selectedNodes()):
    for i in nodes:
        nodeOffset = [0,0]
        oldPos = i.position()
        iType = str(i.type()).split(' for ')[-1][:-1]
        if iType in offsetDict: nodeOffset = offsetDict[iType]
        newPos = i.position()
        newPos[0] = ((2*round(0.5*oldPos[0]+0.25))-0.5) + nodeOffset[0]
        newPos[1]= round(oldPos[1]+0.15)-0.15 + nodeOffset[1]
        i.setPosition(newPos)
        #print "'" + str(i.type()).split(' for ')[-1][:-1] + '\':' + str([x-y for x,y in zip(oldPos,newPos)])+', '
tidyNodes()


And finally the most common one I need to not yell at the everlasting cookfests. I have it set to Alt+Shift+U, which is a bit Vulcan MindMeldy but it works. I also set Alt+U to "/Houdini/Force Update"
import hou
mode = hou.updateModeSetting().name()
if mode == 'AutoUpdate':
    hou.setUpdateMode(hou.updateMode.Manual)
if mode == 'Manual':
    hou.setUpdateMode(hou.updateMode.OnMouseUp)
if mode == 'OnMouseUp':
    hou.setUpdateMode(hou.updateMode.AutoUpdate)

Friday, June 2, 2017

NukeStudio :: Return the source path for a selected clip

from hiero.core import TrackItem
seq = hiero.ui.activeSequence()
te = hiero.ui.getTimelineEditor(seq)
t =te.selection()[-1]
print t.source().mediaSource().fileinfos()[0].filename()

Sunday, May 14, 2017

NukeStudio :: Text expression to display media info

Use this to get file name of the displayed media in NukeStudio:
[lindex [split [metadata input/filename] "/"] end]