lemond Posted April 9, 2010 Share Posted April 9, 2010 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 Quote Link to comment Share on other sites More sharing options...
graham Posted April 9, 2010 Share Posted April 9, 2010 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) Quote Link to comment Share on other sites More sharing options...
lemond Posted April 9, 2010 Author Share Posted April 9, 2010 (edited) 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) Edited April 9, 2010 by lemond Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted April 10, 2010 Share Posted April 10, 2010 (edited) 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 April 10, 2010 by SWANN Quote Link to comment Share on other sites More sharing options...
graham Posted April 10, 2010 Share Posted April 10, 2010 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) Quote Link to comment Share on other sites More sharing options...
lemond Posted April 10, 2010 Author Share Posted April 10, 2010 perfect, thanks again ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.