Hello, I got two specific questions in simulation right now, as they were described in title.
First, I want to use python node to program a few lines of statement that could add color points on the ramp of my color nodes, since I need to add 200 points in order to give my geometry layers of different colors.
(I only know the syntax of how to set node's attribute values with Python, but I did not find out the syntax that can tell the node automatically add points)
Also, as my first screenshot shows, I want to know how to set values to color vector, since color parameter's name is “rampcr#rampgr#rampbr#”, I don't know how to syntax that with values and expressions.
The second question is about generating a bounding box in order to delete exactly half of my volume, but I want the effect operated in the end of my network, because I want the color be set well(i.e. color changes from shell to shell of my spherical volume), and then cut it half, make the cross section of my spherical volume be seen, so that the rings of different colors could be seen more obviously~
I used a delete node as the second screenshot shows, but it did not work, it seems all my volume was disappeared, the whole volume was ghosted in the scene so that you can see what I constructed. I don't know if I set something wrong or I should use another node to achieve my final effect?
It is ok if you can only solve one of my questions, I would be grateful. Thanks a lot in advance!
using python to modify/control color node and bounding box
4075 2 1-
- jingyukan
- Member
- 10 posts
- Joined: May 2020
- Offline
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
1. don't use Python SOP to modify UI of other nodes, as that runs the code every time it cooks and you probably want to set your ramp just once, use Python Source Editor, Shelf Tool, Python Shell, Parameret Callback script, …. instead
but to populate ramp with 200 random colors you can for example do this
2. you can for example clear the density voxel values in Volume Wrangle
but to populate ramp with 200 random colors you can for example do this
import hou import numpy ramp = hou.parm('/obj/geo1/color/ramp') count = 200 ramp.set(count) parms = ramp.multiParmInstances() for i in range(0, len(parms), 5): color = numpy.random.rand(3) parms[i].set( i / 5.0 / count ) parms[i+1].set(color[0]) parms[i+2].set(color[1]) parms[i+3].set(color[2]) parms[i+4].set(0)
2. you can for example clear the density voxel values in Volume Wrangle
f@density *= v@P.x < 0;
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- jingyukan
- Member
- 10 posts
- Joined: May 2020
- Offline
tamte
1. don't use Python SOP to modify UI of other nodes, as that runs the code every time it cooks and you probably want to set your ramp just once, use Python Source Editor, Shelf Tool, Python Shell, Parameret Callback script, …. instead
but to populate ramp with 200 random colors you can for example do thisimport hou import numpy ramp = hou.parm('/obj/geo1/color/ramp') count = 200 ramp.set(count) parms = ramp.multiParmInstances() for i in range(0, len(parms), 5): color = numpy.random.rand(3) parms[i].set( i / 5.0 / count ) parms[i+1].set(color[0]) parms[i+2].set(color[1]) parms[i+3].set(color[2]) parms[i+4].set(0)
2. you can for example clear the density voxel values in Volume Wranglef@density *= v@P.x < 0;
Hello, thanks for helping!
The volume wrangle works well; for color ramp, I modified your coding example, it works for most part, but there is only one problem that I need to give one of the parameter an expression like what I did in screenshot attached. I noticed it did not work like other node's parameter controlled by python. The attribute I need the blue color parameter to read is attribute “waterCd#” with index starts from 0 to 199.
Hope you could teach me the correct syntax~
Many thanks!
By the way, may I ask where I could watch more tutorials about programming in Houdini to simulate scientific visualization, I found that the resource for scientific simulation with Houdini was not really rich so far~
-
- Quick Links

