Showing posts with label UI. Show all posts
Showing posts with label UI. Show all posts

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';

Sunday, February 19, 2017

Houville :: adding params to a obj

Another one I keep forgetting... Here's how to add params to a node in houdini.
n = hou.node('/obj/geo1')
n.addSpareParmTuple(hou.IntParmTemplate('intParm','',1, default_value=(10,),min = 0, max = 20))
n.addSpareParmTuple(hou.FloatParmTemplate('floatParm','',1, default_value=(10,),min = 0, max = 20))


#define some multi line code.  Like a python script
code = """print 'some stuff'
print 'more stuffs'
print 'an\\\\' ting'"""

# is hidden is good for hiding code away
n.addSpareParmTuple(hou.StringParmTemplate('stringParm','',1,default_value=(code,), is_hidden=0))
n.addSpareParmTuple(hou.ButtonParmTemplate('Button','', join_with_next=0, script_callback='exec(hou.parm("stringParm").evalAsString())', script_callback_language=hou.scriptLanguage.Python))

And when you want to delete some parms, remember to get rid of the tuple.  You can access that easily like this:
n.removeSpareParmTuple(n.parm('stringParm').tuple())

And finally, if you don't want to add params one by one you can make a Parameter Template Group to then add as a lump later.
ptg = n.parmTemplateGroup()
ptg.append(hou.IntParmTemplate('intParm','',1, default_value=(10,),min = 0, max = 20))
n.setParmTemplateGroup(ptg)

Not quite sure yet why this is better, but I'll probably find out one day.