Get point indices in prims with Python

   4049   1   0
User Avatar
Member
9 posts
Joined: April 2015
Offline
Hi,
I am trying to access the point indices prims are made up of in Python.

Currently I am doing this with:

for k in geo.prims():
MyCurrentFace = k
NumVertsCurrentFace = MyCurrentFace.numVertices()

for Verts in MyCurrentFace.vertices():
VertsCurrentFace = Verts.point().number()
print VertsCurrentFace




It works but it is relatively slow.
In another thread where I asked how to access point positions I was told that it would be very fast with using:

hou.Geometry.pointFloatAttribValues(geo,“P”)

That worked very fast.
So my question is, is it possible to get the point indices of individual faces in a similar way?

I have so far tried to create relevant Attributs with nodes such as the attribcreate node, but I wasn´t sucessful.
I did some other tests and manged to create Attributes such as Normals and similar things with nodes which I was then able to access with Python. But I have so far not managed to create Attributes for point index per prim.
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
No other way. If need particular prim, or range of prims, better use generator (iterPrims):

points_ids = [vtx.point().number() for vtx in geo.iterPrims().vertices()]


If you'r iterating over all prims there is no big difference in speed between prims() and iterPrims() other than more memory consumption.
Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
  • Quick Links