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
2435 5 1- socratica
- Member
- 6 posts
- Joined: Feb. 2019
- Offline
- jsmack
- Member
- 7802 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
- 900 posts
- Joined: Feb. 2016
- Offline
- socratica
- Member
- 6 posts
- Joined: Feb. 2019
- Offline
- animatrix_
- Member
- 4528 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]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
-
- Quick Links