Jump to content

echo commands within Houdini?


lemond

Recommended Posts

When I select or modify a transform, I'd like to see that command's output.

Does this feature exist?

If no, can someone share a script that allows the user to change selected values on multiple objects?

For example, I select the values of many objects and set those values to 5? Yes, I know you can easily do this with the UI, but I want a script for it.

TIA

Link to comment
Share on other sites

You can get very limited echoing with the 'commandecho' hscript command, however it doesn't output information when you change parameters for example. Mostly just node creation type stuff.

Really all you are doing is running an 'opparm' command on a parameter when you change it.

A script to change values is pretty basic.

def changeParms(node_list, parm_name, value):
    for node in node_list:
        node.parm(parm_name).set(value)

some_nodes = hou.selectedNodes()

changeParms(some_nodes, "ty", 5)

Link to comment
Share on other sites

Guest Swann

thanks Graham!

One last easy one, how could I change that 5 to a random number, say between 0 and 10?

I'd like to have something like this -

fit01(rand($OBJ), 0, 10)

I supose something like this

# add this line to your script
from random import randrange

# then you can use randrange function directly
changeParms(some_nodes, "ty", randrange(0, 10))

should work, but still you will have to put this into loop to get different values for each object

Edited by SWANN
Link to comment
Share on other sites

You could do something like this using a nodes unique session ID to act as the seed for a random. You can then run it through fit01(). The hou.hmath submodule has most of the common mathematical functions available to Hscript expressions. In the interest of making the function as general as possible I've changed it to take the min/max values as arguements. This function can work on any node type, not just objects.

def randomizeParmValue(node_list, parm_name, min, max):
    for node in node_list:
        value = hou.hmath.fit01(hou.hmath.rand(node.sessionId()), min, max)
        node.parm(parm_name).set(value)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...