Skip to content

Instantly share code, notes, and snippets.

@mattebb
Last active December 22, 2015 06:48
Show Gist options
  • Save mattebb/6433463 to your computer and use it in GitHub Desktop.
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.
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')
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