Hello everyone,
I've looked through the documentation thoroughly, and I can't find a simple way to find all primitives with a specific name.
Using Python it can be done with a short list comprehension:
(bracket) prim for prim in geo.prims() if prim.attribValue(“name”) == “michael” (closed bracket)
But this loops over every single primitive.
Q: Is there a faster way to do this rather than looping over all prims?
(My hope is that Houdini indexes things by name for super fast lookup.)
Thanks!
~Michael
Finding primitives by name
3660 5 1-
- socratica
- Member
- 6 posts
- Joined: Feb. 2019
- Offline
-
- jsmack
- Member
- 8173 posts
- Joined: Sept. 2011
- Offline
-
- socratica
- Member
- 6 posts
- Joined: Feb. 2019
- Offline
I was going to use a group, but I read on the Node name docs [www.sidefx.com] that names are more efficient than groups. So I was hoping to get used to using names for a lot of my computations in Python nodes.
My gut tells me I'm prematurely optimizing… But I'm still curious if there's a method that will return all primitives with a given name.
My gut tells me I'm prematurely optimizing… But I'm still curious if there's a method that will return all primitives with a given name.
-
- Andr
- Member
- 899 posts
- Joined: Feb. 2016
- Offline
-
- socratica
- Member
- 6 posts
- Joined: Feb. 2019
- Offline
-
- animatrix_
- Member
- 5040 posts
- Joined: Feb. 2012
- Offline
You can use the nametoprim VEX function which uses findattribval function which is way faster than looping over primitives manually.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]

-
- Quick Links