Yalf Posted October 2, 2019 Share Posted October 2, 2019 Hello, I am new to Houdini. I am creating a building generation tool. I want to randomize parameters of my "controller", which is just a null node with parameters, that control the buildings length, height, number of windows etc. I want to randomize these parameters with a python script last of all nodes in the network. This is how I try to do it, but it doesn't work and I don't understand the error. nrOfWindows = `chs("../controller/nrOfVertWin")` print nrOfWindows nrOfWindows = nrOfWindows + 1 print nrOfWindows `chs("../controller/nrOfVertWin")` = nrOfWindows Any help is appreciated, thanks! Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted October 2, 2019 Share Posted October 2, 2019 `chs...` is a hscript syntax. It's better to use full python if you're going to use python. Something like import random controller_node = hou.pwd().parent().node("controller") windows_parm = controller_node.parm("nOfVertWin") windows_parm.set(random.randint(0, 5)) This would randomize between 0 and 5. Quote Link to comment Share on other sites More sharing options...
Yalf Posted October 3, 2019 Author Share Posted October 3, 2019 Thank you, this works great! If I could just bother you with one more question that would be even better! How do I re-initialize a python node? If I want this random number to change every time I click the python node? If I change something in the script it will re-initialize, but that is a bit tedious. Is there a better way? Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted October 3, 2019 Share Posted October 3, 2019 You can try forcing the cook of a node with `node.cook(force=True)`. But usually you would make a button that would let the user randomize whatever on demand. You can also take a look at PDG to make a graph that constructs your assets. Quote Link to comment Share on other sites More sharing options...
Yalf Posted October 4, 2019 Author Share Posted October 4, 2019 Oh right, that sounds great! Thanks so much for all the help! 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.