Hi, I've got a model, then I've added the “point” node. How can I using only expressions set the positions of the points to the centers of polygons of the model on the begining? I was trying do it with expressions and I can't find way to do it.
With nodes I could make faced- skale faces down and fuse points, but how with only expr?
I forgot to write, that I'm trying to achive this effect in python …. I was trying to access this parameter so: hou.node('../torus').prims(). …? and I can't find way to access the parameter
In HOM there isn't a simple hou.Prim.position() function that returns the center of the primitive. To get that you'll need to calculate the centroid yourself based on the vertex positions.
The equivalent to the prim() expression is something like this: prim = hou.Node.geometry().iterPrims() centroid = sum((vert.point().position() for vert in prim.vertices()), hou.Vector3()) * (1.0 / prim.numVertices()) return centroid
Edited by - Oct. 1, 2009 16:54:56
Graham Thompson, Technical Artist @ Rockstar Games
Unfortunately no, P is not really a primitive attribute. If you inspect some geometry using the Spreadsheet/Details view you will see that there isn't actually a P attribute under Primitives. It is a calculated value.
Unfortunately the above method is what you need to do. I also modified my code slightly to use iterPrims() instead of prims() since we are only getting a single prim entry and this will be faster. My suggestion would be to write a simple function and put it in your pythonrc.py file so you can call it more cleanly from inside Houdini.
Edit:
Here's something you can place in your pythonrc.py file and all you have to do is call hou.Prim.position().
hou.Node.geometry().iterPrims().position()
def getPrimPosition(self): “”“ Return the position of this primitive as a Vector3 containing the (X, Y, Z) position values. ”“” return sum((vert.point().position() for vert in self.vertices()), hou.Vector3()) * (1.0 / self.numVertices())
hou.Prim.position = getPrimPosition
Graham Thompson, Technical Artist @ Rockstar Games