Saturday, March 25, 2017

Python: copy paste buffer

Seems like PyQt4 is the ideal way to go:

Two styles:
##how to get something into the clipboard / copy/paste buffer
from PyQt4 import QtGui
QtGui.QApplication.clipboard().setText(textString)

##and to get it back out
text = QtGui.QApplication.clipboard().text()

##but it will be a QString so you'll probably want to 
textString = str(text)


In some cases PyQt4 seems to be crippled, so you can also use Tkinter, which seems to work well for extracting from clipboard. Haven't had luck putting stuff in though:
import Tkinter
root = Tkinter.Tk()
root.withdraw() # Hide the main window (optional)
rawClip = root.clipboard_get()

Saturday, March 11, 2017

Nukia - smarter switch

Use in text node to find what Switch1 Reads are looking at. [lindex [split [file tail [value [value Switch1.input[expr int([value Switch1.which])].name].file]] -] 0] or lol.. [lindex [split [file tail [value [value [value this.input0.name].input[expr int([value [value this.input0.name].which])].name].file]] -] 0] This is also useful. Root dir: [file dirname [knob [topnode].file] ] File name: [file tail [knob [topnode].file] ] File extension: [file extension [knob [topnode].file] ]

Friday, March 10, 2017

Houville :: rop presets

nodePath = ropnet.createNode('ifd',node_name).path()
hscript = "oppresetloadfile %s %s" % (nodePath, "niceRopLayout.preset")
hou.hscript(hscript)

Friday, March 3, 2017

Houville :: put points in the centre of prims

Points in centre of prim, and delete points:
addpoint(0, @P);
removeprim(0, @primnum, 1);


==EDIT== Just realised it can be handy to pull attributes from the prim on to the newly created points in the same primwrangle.
Here's how:
int newPt = addpoint(0, @P);
addpointattrib(0,"N",{0,0,0});
setpointattrib(0,"N", newPt, @N, "add");
removeprim(0, @primnum, 1);