hom volume primitive name

   3576   2   1
User Avatar
Member
380 posts
Joined: July 2005
Offline
Hi there, trying to find a way to parse volume primitives by name,
so i can infer the index of the primitive i want (in particular rest)
MMB on my incoming volume i see:

Volume Resolutions:
0 (density) : Voxel Count: 275,282
1 (vel.x) : Voxel Count: 280,476
2 (vel.y) : Voxel Count: 278,091
3 (vel.z) : Voxel Count: 280,476
4 (rest.x) : Voxel Count: 275,282
5 (rest.y) : Voxel Count: 275,282
6 (rest.z) : Voxel Count: 275,282
7 (rest2.x) : Voxel Count: 275,282
8 (rest2.y) : Voxel Count: 275,282
9 (rest2.z) : Voxel Count: 275,282

And i want to get the index of the prims that start with the
name rest. Can anyone point me in the right direction?
cheers.


>>> n = hou.node('/obj/GET/vol_Noise/VOL_IN')
>>> g = n.geometry()
>>> prims = g.prims()
>>> p4 = prims
>>> p4.type()
primType.Volume
>>> p4.number()
>>> 4
User Avatar
Member
380 posts
Joined: July 2005
Offline
ah, primitive attribute lookup:


>>> pattrs = g.primAttribs()
>>> pattrs
(<hou.Attrib Prim ‘maximum’ (1 Float) of geometry in /obj/GET/vol_Noise/VOL_IN>, <hou.Attrib Prim ‘minimum’ (1 Flo
at) of geometry in /obj/GET/vol_Noise/VOL_IN>, <hou.Attrib Prim ‘dopobject’ (1 String) of geometry in /obj/GET/vol
_Noise/VOL_IN>, <hou.Attrib Prim ‘name’ (1 String) of geometry in /obj/GET/vol_Noise/VOL_IN>)
>>> pattrs.strings()
('density', ‘vel.x’, ‘vel.y’, ‘vel.z’, ‘rest.x’, ‘rest.y’, ‘rest.z’, ‘rest2.x’, ‘rest2.y’, ‘rest2.z’)


Afterwhich its straightforward to infer the primitive index from the name.
User Avatar
Member
127 posts
Joined: Nov. 2008
Offline
you can use listbyvals expression.

from help:

string listbyvals (string surface_node, float class, string attribute, string id)
Returns a list of elements with a given value for a string attribute.

The <class> can be one of D_VERTEX, D_POINT, D_PRIMITIVE, or D_DETAIL
for the corresponding attribute class.

EXAMPLES
listbyvals(“/obj/geo1/facet1”, D_PRIMITIVE, “name”, “piece1”)

Returns a list of primitives with a value of piece1 for the name
attribute in the facet1 surface node in geo1.
Bhavesh Pandey.

https://bhaveshpandey.io [bhaveshpandey.io]
  • Quick Links