Last active
December 22, 2015 06:48
-
-
Save mattebb/6433463 to your computer and use it in GitHub Desktop.
Handy shortcut to add an Import Attribute or Add Attribute VOP node, guessing the values of input parameters. Intended for binding to a shortcut key.
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
selpath = hou.hscriptExpression('mousepath()').split('.')[-1] | |
voppath = '/'.join( selpath.split('/')[:-1] ) | |
node = hou.node(voppath) | |
retval, aname = hou.ui.readInput("Attribute Name", buttons=('OK',)) | |
if retval != -1: | |
add = node.createNode('addattrib') | |
add.setName("add_%s"%aname) | |
add.parm('attrib').set(aname) | |
add.parm('localvar').set(aname.upper()) | |
if aname == 'orient': | |
add.parm('typemodifier').set('quaternion') |
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
selpath = hou.hscriptExpression('mousepath()').split('.')[-1] | |
voppath = '/'.join( selpath.split('/')[:-1] ) | |
node = hou.node(voppath) | |
retval, aname = hou.ui.readInput("Attribute Name", buttons=('OK',)) | |
attrib = node.inputs()[0].geometry().findPointAttrib(aname) | |
if attrib != None: | |
adt = attrib.dataType() | |
asize = attrib.size() | |
else: | |
adt = hou.attribData.Float | |
asize = 1 | |
if retval != -1: | |
imp = node.createNode('importattrib') | |
imp.setName("import_%s"%aname) | |
imp.parm('attrib').set(aname) | |
if adt == hou.attribData.Float and asize == 3: | |
imp.parm('signature').set('default') | |
elif adt == hou.attribData.Float and asize == 9: | |
imp.parm('signature').set('m3') | |
elif adt == hou.attribData.Float and asize == 16: | |
imp.parm('signature').set('m') | |
elif adt == hou.attribData.Float: | |
imp.parm('signature').set('f') | |
elif adt == hou.attribData.Int: | |
imp.parm('signature').set('i') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment