I want to get the normal of each of the points as defined by a grid.
How should I achieve this by using the python code in Houdini?
I've tried the following code, but it doesn't work…
(in the following node, the hou.pwd() is the grid created)
def write_point_normal(file, point):
point_normal = point.attribValue(“n”)
file.write(str(point_normal) + “ ” +\
str(point_normal) + “ ” +\
str(point_normal) + “\n”)
points = hou.pwd().geometry().points()
for point in points:
write_point_normal(file, point)
can anybody help to shed light on this?
Thanks!
Ji
how to get the normal of a point via python script?
4448 1 1- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
- graham
- Member
- 1908 posts
- Joined: Nov. 2006
- Online
Assuming the normal attribute exists it is named “N”, not “n”. Notice this when you MMB on the node. However, if as you say you are running this code from a Grid Sop then this will not work as there is no Normal attribute.
geo = hou.pwd().geometry()
attrib_pointer = geo.findPointAttrib(“N”)
if attrib_pointer is not None:
for point in hou.pwd().geometry().points():
attrib_value = point.attribValue(attrib_pointer)
file.write(“%s %s %s\n” % attrib_value)
geo = hou.pwd().geometry()
attrib_pointer = geo.findPointAttrib(“N”)
if attrib_pointer is not None:
for point in hou.pwd().geometry().points():
attrib_value = point.attribValue(attrib_pointer)
file.write(“%s %s %s\n” % attrib_value)
Graham Thompson, Technical Artist @ Rockstar Games
-
- Quick Links